From fab282eb800ef5626f85f3c876e797b4fc472e0d Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Fri, 11 Oct 2013 15:07:57 +0000 Subject: use md5 for checksum, use long expire, always return not modified --- itjs.php | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'itjs.php') diff --git a/itjs.php b/itjs.php index 9f5cc78..65a78fe 100644 --- a/itjs.php +++ b/itjs.php @@ -26,6 +26,11 @@ require "itools/itools.lib"; if (EDC('slowjs')) sleep(20); +if ($_SERVER['HTTP_IF_NONE_MATCH'] && it::is_live() && !$_REQUEST['retry']) { + header("HTTP/1.0 304 Not Modified"); # client should always keep the component that fits the page it has + exit; +} + $data = ""; $files = itjs::filenames(it::match('/itjs/([a-z0-9_,.-]*)', $_SERVER['PHP_SELF'])); @@ -64,23 +69,21 @@ else if (!it::match('\.html$', $file)) @header("Etag: $checksum"); -if ($checksum != $_SERVER['HTTP_IF_NONE_MATCH'] || $_REQUEST['retry']) +if (!preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']) && it::is_live() && !$_REQUEST['retry']) { - if (!preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT']) && it::is_live() && !$_REQUEST['retry']) - header("Cache-Control: max-age=900"); - - $data = itjs::strip($data); + header("Cache-Control: max-age=604800"); + header("Expires: " . gmdate("D, d M Y H:i:s", time()+604800). " GMT"); +} - if ($_REQUEST['boot']) - { - $data .= "window.it_boot_init();\n"; - if (!$_REQUEST['script']) - $data = sprintf("/*sln:%d*/\n%s/*eln:%d*/", grapheme_strlen($data), strtr($data, array('%' => "%25", '.' => "%2e", 'e' => "%65", 'i' => "%69")), grapheme_strlen($data)); # Protect from Firewalls/Proxies altering Javascript source code - } +$data = itjs::strip($data); - echo it_untaint($data); +if ($_REQUEST['boot']) +{ + $data .= "window.it_boot_init();\n"; + if (!$_REQUEST['script']) + $data = sprintf("/*sln:%d*/\n%s/*eln:%d*/", grapheme_strlen($data), strtr($data, array('%' => "%25", '.' => "%2e", 'e' => "%65", 'i' => "%69")), grapheme_strlen($data)); # Protect from Firewalls/Proxies altering Javascript source code } -else - header("HTTP/1.0 304 Not Modified"); + +echo it_untaint($data); ?> -- cgit v1.2.3