Skip to content

Commit

Permalink
MDL-28709 adding HTTP_IF_MODIFIED_SINCE and minor style tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Aug 19, 2011
1 parent ccc0fff commit aa603b1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
5 changes: 2 additions & 3 deletions theme/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@
$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);
Expand Down
4 changes: 2 additions & 2 deletions theme/javascript.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@
$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');
Expand Down
4 changes: 2 additions & 2 deletions theme/styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@
$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');
Expand Down
2 changes: 1 addition & 1 deletion theme/yui_combo.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
// 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);
Expand Down

0 comments on commit aa603b1

Please sign in to comment.