aboutsummaryrefslogtreecommitdiff
path: root/engine/handlers
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2012-01-08 10:06:58 -0500
committerCash Costello <cash.costello@gmail.com>2012-01-08 10:06:58 -0500
commitd213db79744507ab6e601167d158f256764d785e (patch)
treeee09e7624ab280a9284c9b71e2da861b486df3e6 /engine/handlers
parent3b496d923045770bdf4b25452fa63253927ee56a (diff)
downloadelgg-d213db79744507ab6e601167d158f256764d785e.tar.gz
elgg-d213db79744507ab6e601167d158f256764d785e.tar.bz2
Fixes #2002 adds ETag support to simple cache handler
Diffstat (limited to 'engine/handlers')
-rw-r--r--engine/handlers/cache_handler.php21
1 files changed, 13 insertions, 8 deletions
diff --git a/engine/handlers/cache_handler.php b/engine/handlers/cache_handler.php
index 94a0e64e9..b332ec379 100644
--- a/engine/handlers/cache_handler.php
+++ b/engine/handlers/cache_handler.php
@@ -60,26 +60,31 @@ preg_match($regex, $request, $matches);
$type = $matches[1];
$viewtype = $matches[2];
$view = $matches[3];
+$ts = $matches[4];
+
+// If is the same ETag, content didn't changed.
+$etag = $ts;
+if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
+ header("HTTP/1.1 304 Not Modified");
+ exit;
+}
switch ($type) {
case 'css':
header("Content-type: text/css", true);
- header('Expires: ' . date('r', strtotime("+6 months")), true);
- header("Pragma: public", true);
- header("Cache-Control: public", true);
-
$view = "css/$view";
break;
case 'js':
header('Content-type: text/javascript', true);
- header('Expires: ' . date('r', strtotime("+6 months")), true);
- header("Pragma: public", true);
- header("Cache-Control: public", true);
-
$view = "js/$view";
break;
}
+header('Expires: ' . date('r', strtotime("+6 months")), true);
+header("Pragma: public", true);
+header("Cache-Control: public", true);
+header("ETag: $etag");
+
$filename = $dataroot . 'views_simplecache/' . md5($viewtype . $view);
if (file_exists($filename)) {