Skip to content

Commit

Permalink
Pass back Cache-Control and Expires headers when we send back a 304,
Browse files Browse the repository at this point in the history
otherwise some browsers (Firefox, at least) thinks that it needs to
revalidate.  At least in my case, it appears that my proxy tacks on
restrictive Cache-Control headers if they aren't there.
  • Loading branch information
bharat committed Jun 30, 2009
1 parent 3a260ed commit 02b4683
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion modules/gallery/controllers/combined.php
Expand Up @@ -45,6 +45,9 @@ private function _emit($type, $key) {
// Our data is immutable, so if they already have a copy then it needs no updating.
if ($input->server("HTTP_IF_MODIFIED_SINCE")) {
header('HTTP/1.0 304 Not Modified');
header("Expires: Tue, 19 Jan 2038 00:00:00 GMT");
header("Cache-Control: max-age=2678400");
header('Pragma: public');
return;
}

Expand All @@ -60,7 +63,6 @@ private function _emit($type, $key) {
(strpos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false);
if ($use_gzip && $content = $cache->get("{$key}_gz")) {
header("Content-Encoding: gzip");
header("Cache-Control: public");
} else {
// Fall back to non-gzipped if we have to
$content = $cache->get($key);
Expand All @@ -73,6 +75,8 @@ private function _emit($type, $key) {
// $type is either 'javascript' or 'css'
header("Content-Type: text/$type; charset=UTF-8");
header("Expires: Tue, 19 Jan 2038 00:00:00 GMT");
header("Cache-Control: max-age=2678400");
header('Pragma: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time()));

Kohana::close_buffers(false);
Expand Down

0 comments on commit 02b4683

Please sign in to comment.