summaryrefslogtreecommitdiff
path: root/itjs.class
diff options
context:
space:
mode:
authorUrban Müller2015-10-28 18:51:39 +0100
committerUrban Müller2015-11-09 14:29:17 +0100
commit9aab17be924ec04b7b46a971d3c9f414f6eb9bf0 (patch)
tree7dcf5ed970f4ca6d83b4ed152b9f32863434c7b5 /itjs.class
parent7c8d68afbf676446f6446f9bdf8bcbfafa92bdcf (diff)
downloaditools-9aab17be924ec04b7b46a971d3c9f414f6eb9bf0.tar.gz
itools-9aab17be924ec04b7b46a971d3c9f414f6eb9bf0.tar.bz2
itools-9aab17be924ec04b7b46a971d3c9f414f6eb9bf0.zip
extract far future header handling for ffe.php
Diffstat (limited to 'itjs.class')
-rw-r--r--itjs.class20
1 files changed, 20 insertions, 0 deletions
diff --git a/itjs.class b/itjs.class
index b8520f5..f76620f 100644
--- a/itjs.class
+++ b/itjs.class
@@ -217,6 +217,26 @@ function crcurl($url)
return it::match('#', $url) ? U(trim($url, "#")) : U($url, array('c' => self::checksum(array($fn))));
}
+static function far_future_headers()
+{
+ $crc = $_REQUEST['c'] ?: $_REQUEST['s'];
+ if ($crc != "-" && !$_SERVER['HTTP_CACHE_CONTROL'] && $_SERVER['HTTP_IF_NONE_MATCH'] && !it::is_devel() && !$_REQUEST['retry'])
+ {
+ header("HTTP/1.0 304 Not Modified"); # client should always keep the component that fits the page it has
+ exit;
+ }
+
+ if ($crc != "-")
+ @header("Etag: alwaysvalid"); # we have checksums in the url. client should always keep the version he downloaded along with the html
+
+ if (it::is_live() && !$_REQUEST['retry'])
+ {
+ $keeptime = $crc == "-" ? 0 : ($crc ? 30*86400 : 900); # long expire if checksum present
+ header("Cache-Control: max-age=$keeptime, private"); # proxies should not cache since contents of same url can differ between browsers
+ header("Expires: " . gmdate("D, d M Y H:i:s", time() + $keeptime). " GMT");
+ }
+}
+
}
?>