From 4179279e4bb7e654ba44924821a2fdd62e1e1846 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 16 Nov 2015 13:59:53 +0100 Subject: make c= optional for far future expire --- itjs.class | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/itjs.class b/itjs.class index e69696a..92a1c58 100644 --- a/itjs.class +++ b/itjs.class @@ -217,7 +217,8 @@ function crcurl($url, $p = array()) return it::match('#', $url) ? U(trim($url, "#")) : U($url, array('c' => self::checksum(array($fn), array('short_expire' => $short_expire)))); } -static function far_future_headers() +# $p['nocrc'] means no $_REQUEST['c'] is needed for far future expire +static function far_future_headers($p = []) { $crc = $_REQUEST['c'] ?: $_REQUEST['s']; if ($crc != "-" && !$_SERVER['HTTP_CACHE_CONTROL'] && $_SERVER['HTTP_IF_NONE_MATCH'] && !it::is_devel() && !$_REQUEST['retry']) @@ -231,7 +232,7 @@ static function far_future_headers() if (it::is_live() && !$_REQUEST['retry']) { - $keeptime = $crc == "-" ? 0 : ($crc ? 30*86400 : 900); # long expire if checksum present + $keeptime = $crc == "-" ? 0 : ($crc || $p['nocrc'] ? 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"); } -- cgit v1.2.3