]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #4142. Added ETag header support for user avatars.
authorSem <sembrestels@riseup.net>
Tue, 3 Jan 2012 15:13:57 +0000 (16:13 +0100)
committerCash Costello <cash.costello@gmail.com>
Sat, 7 Jan 2012 16:58:26 +0000 (11:58 -0500)
mod/profile/icondirect.php

index f7188455e40ce86c803bb9823e7a13febb1ab2a1..1680d8fce4798d206b8066f5681f2f909e559a53 100644 (file)
@@ -12,8 +12,16 @@ require_once(dirname(dirname(dirname(__FILE__))). '/engine/settings.php');
 global $CONFIG;
 
 $join_date = (int)$_GET['joindate'];
+$last_cache = (int)$_GET['lastcache']; // icontime
 $guid = (int)$_GET['guid'];
 
+// If is the same eTag, content didn't changed.
+$eTag = $last_cache . $guid;
+if (trim($_SERVER['HTTP_IF_NONE_MATCH']) == $eTag) {
+       header("HTTP/1.1 304 Not Modified");
+       exit;
+}
+
 $size = strtolower($_GET['size']);
 if (!in_array($size, array('large', 'medium', 'small', 'tiny', 'master', 'topbar'))) {
        $size = "medium";
@@ -48,6 +56,7 @@ if ($mysql_dblink) {
                                header("Pragma: public");
                                header("Cache-Control: public");
                                header("Content-Length: " . strlen($contents));
+                               header("ETag: $eTag");
                                // this chunking is done for supposedly better performance
                                $split_string = str_split($contents, 1024);
                                foreach ($split_string as $chunk) {