add EXPIRES header even in HTTP 304 not modified

This commit is contained in:
Joshua Seigler 2016-06-26 13:37:54 -04:00
parent 4d78085a3c
commit b1e5fababa

View file

@ -31,6 +31,7 @@
// always send headers // always send headers
header("Last-Modified: ".gmdate("D, d M Y H:i:s", $last_modified_time)." GMT"); header("Last-Modified: ".gmdate("D, d M Y H:i:s", $last_modified_time)." GMT");
header("Etag: $etag"); header("Etag: $etag");
header("Expires: ".gmdate("D, d M Y H:i:s", $last_modified_time + CACHE_TIME)." GMT");
// exit if not modified // exit if not modified
if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time || if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time ||
@ -40,7 +41,6 @@
} }
// if so, display cache file and stop processing // if so, display cache file and stop processing
header("Expires: ".gmdate("D, d M Y H:i:s", $last_modified_time + CACHE_TIME)." GMT");
readfile($file); readfile($file);
exit; exit;
} }
@ -52,7 +52,7 @@
fwrite($f, $content); fwrite($f, $content);
fclose($f); fclose($f);
} }
$last_modified_time = filemtime($file); $last_modified_time = time();
$etag = md5_file($file); $etag = md5_file($file);
// always send headers // always send headers