diff --git a/theme/image.php b/theme/image.php index 2ec860dc1bd..cac1765bd22 100644 --- a/theme/image.php +++ b/theme/image.php @@ -71,13 +71,12 @@ if ($rev > -1) { $ext = 'ico'; } if ($cacheimage) { - if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) { + 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 - header('HTTP/1.1 304 Not Modified'); - $lifetime = 60*60*24*30; // 30 days $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'); header('Cache-Control: max-age='.$lifetime); header('Content-Type: '.$mimetype); diff --git a/theme/javascript.php b/theme/javascript.php index d5d0d55aa5e..9b359a1f97a 100644 --- a/theme/javascript.php +++ b/theme/javascript.php @@ -49,11 +49,11 @@ if (file_exists("$CFG->dirroot/theme/$themename/config.php")) { $candidate = "$CFG->dataroot/cache/theme/$themename/javascript_$type.js"; if ($rev > -1 and file_exists($candidate)) { - if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) { + 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 - header('HTTP/1.1 304 Not Modified'); $lifetime = 60*60*24*30; // 30 days + header('HTTP/1.1 304 Not Modified'); header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT'); header('Cache-Control: max-age='.$lifetime); header('Content-Type: application/javascript; charset=utf-8'); diff --git a/theme/styles.php b/theme/styles.php index 2a086262772..ce6ada05da9 100644 --- a/theme/styles.php +++ b/theme/styles.php @@ -53,11 +53,11 @@ if ($type === 'ie') { $candidatesheet = "$CFG->dataroot/cache/theme/$themename/css/$type.css"; if (file_exists($candidatesheet)) { - if (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) { + 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 - header('HTTP/1.1 304 Not Modified'); $lifetime = 60*60*24*30; // 30 days + header('HTTP/1.1 304 Not Modified'); header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT'); header('Cache-Control: max-age='.$lifetime); header('Content-Type: text/css; charset=utf-8'); diff --git a/theme/yui_combo.php b/theme/yui_combo.php index f3dba345c90..8d46a1d7148 100644 --- a/theme/yui_combo.php +++ b/theme/yui_combo.php @@ -49,8 +49,8 @@ if (substr($parts, -3) === '.js') { // If-Modified-Since header, we can send back a 304 Not Modified since the // content never changes (the rev number is increased any time the content changes) if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { - header('HTTP/1.1 304 Not Modified'); $lifetime = 60*60*24*30; // 30 days + header('HTTP/1.1 304 Not Modified'); header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT'); header('Cache-Control: max-age='.$lifetime); header('Content-Type: '.$mimetype);