MDL-57789 files: Reviewed lifetime value

This commit is contained in:
Matteo Scaramuccia 2017-02-12 00:07:15 +01:00
parent ed0a1cd708
commit 203c5bce27
7 changed files with 24 additions and 17 deletions

View File

@ -284,8 +284,8 @@ function css_chunk_by_selector_count($css, $importurl, $maxselectors = 4095, $bu
* @param string $etag The revision to make sure we utilise any caches.
*/
function css_send_cached_css($csspath, $etag) {
// 60 days only - the revision may get incremented quite often.
$lifetime = 60*60*24*60;
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
header('Etag: "'.$etag.'"');
header('Content-Disposition: inline; filename="styles.php"');
@ -310,8 +310,8 @@ function css_send_cached_css($csspath, $etag) {
* @param string $etag The revision to make sure we utilise any caches.
*/
function css_send_cached_css_content($csscontent, $etag) {
// 60 days only - the revision may get incremented quite often.
$lifetime = 60*60*24*60;
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
header('Etag: "'.$etag.'"');
header('Content-Disposition: inline; filename="styles.php"');
@ -363,8 +363,8 @@ function css_send_uncached_css($css) {
* @param string $etag
*/
function css_send_unmodified($lastmodified, $etag) {
// 60 days only - the revision may get incremented quite often.
$lifetime = 60*60*24*60;
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
header('HTTP/1.1 304 Not Modified');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Cache-Control: public, max-age='.$lifetime);

View File

@ -2201,7 +2201,7 @@ function send_file($path, $filename, $lifetime = null , $filter=0, $pathisstring
$immutable = ', immutable';
// Overwrite lifetime accordingly:
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetimemin = 60*60*24*90;
$lifetimemin = 60 * 60 * 24 * 90;
$lifetime = max($lifetime, $lifetimemin);
}
$cacheability = ' public,';

View File

@ -34,7 +34,8 @@ defined('MOODLE_INTERNAL') || die();
function js_send_cached($jspath, $etag, $filename = 'javascript.php') {
require(__DIR__ . '/xsendfilelib.php');
$lifetime = 60*60*24*60; // 60 days only - the revision may get incremented quite often
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
header('Etag: "'.$etag.'"');
header('Content-Disposition: inline; filename="'.$filename.'"');
@ -81,7 +82,8 @@ function js_send_uncached($js, $filename = 'javascript.php') {
* @param string $etag
*/
function js_send_unmodified($lastmodified, $etag) {
$lifetime = 60*60*24*60; // 60 days only - the revision may get incremented quite often
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
header('HTTP/1.1 304 Not Modified');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Cache-Control: public, max-age='.$lifetime);

View File

@ -106,7 +106,8 @@ if ($rev > 0) {
if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
// We do not actually need to verify the etag value because our files
// never change in cache because we increment the rev parameter.
$lifetime = 60*60*24*60; // 60 days only - the revision may get incremented quite often.
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
header('HTTP/1.1 304 Not Modified');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Cache-Control: public, max-age='.$lifetime);
@ -173,7 +174,8 @@ function send_cached_font($fontpath, $etag, $font, $mimetype) {
global $CFG;
require("$CFG->dirroot/lib/xsendfilelib.php");
$lifetime = 60*60*24*60; // 60 days only - the revision may get incremented quite often.
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
header('Etag: "'.$etag.'"');
header('Content-Disposition: inline; filename="'.$font.'"');

View File

@ -105,9 +105,10 @@ if ($rev > 0) {
}
if ($cacheimage) {
if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
// we do not actually need to verify the etag value because our files
// never change in cache because we increment the rev parameter
$lifetime = 60*60*24*60; // 60 days only - the revision may get incremented quite often
// We do not actually need to verify the etag value because our files
// never change in cache because we increment the rev parameter.
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
$mimetype = get_contenttype_from_ext($ext);
header('HTTP/1.1 304 Not Modified');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
@ -219,7 +220,8 @@ function send_cached_image($imagepath, $etag) {
global $CFG;
require("$CFG->dirroot/lib/xsendfilelib.php");
$lifetime = 60*60*24*60; // 60 days only - the revision may get incremented quite often
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
$pathinfo = pathinfo($imagepath);
$imagename = $pathinfo['filename'].'.'.$pathinfo['extension'];

View File

@ -76,7 +76,8 @@ if (!$file or is_dir($file)) {
}
$etag = sha1("$component/$path");
$lifetime = 60*60*24*120; // 120 days should be enough.
// 90 days only - based on Moodle point release cadence being every 3 months.
$lifetime = 60 * 60 * 24 * 90;
$pathinfo = pathinfo($path);
if (empty($pathinfo['extension'])) {

View File

@ -123,7 +123,7 @@ function yui_image_cached($imagepath, $imagename, $mimetype, $etag) {
header('Last-Modified: '. gmdate('D, d M Y H:i:s', filemtime($imagepath)) .' GMT');
header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
header('Pragma: ');
header('Cache-Control: public, max-age=315360000, no-transform, immutable');
header('Cache-Control: public, max-age='.$lifetime.', no-transform, immutable');
header('Accept-Ranges: none');
header('Content-Type: '.$mimetype);
header('Content-Length: '.filesize($imagepath));