summaryrefslogtreecommitdiff
path: root/itjs.php
diff options
context:
space:
mode:
authorUrban Müller2013-10-11 15:07:57 +0000
committerUrban Müller2013-10-11 15:07:57 +0000
commitfab282eb800ef5626f85f3c876e797b4fc472e0d (patch)
tree99a43ef414e26b8d14b8430559d4897f0abebfcf /itjs.php
parentfb31f42b294161a1f2686413f2cb710e5a1a609a (diff)
downloaditools-fab282eb800ef5626f85f3c876e797b4fc472e0d.tar.gz
itools-fab282eb800ef5626f85f3c876e797b4fc472e0d.tar.bz2
itools-fab282eb800ef5626f85f3c876e797b4fc472e0d.zip
use md5 for checksum, use long expire, always return not modified
Diffstat (limited to 'itjs.php')
-rw-r--r--itjs.php31
1 files changed, 17 insertions, 14 deletions
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);
?>