Commit:    177746bd81dd0b8635db8c8a5d5245ac0a72ffd8
Author:    Hannes Magnusson <[email protected]>         Fri, 6 Dec 2013 
17:00:35 -0800
Parents:   c3d2b369f40a93fb6fb230a98d3ab7a739ab729d
Branches:  master

Link:       
http://git.php.net/?p=web/php.git;a=commitdiff;h=177746bd81dd0b8635db8c8a5d5245ac0a72ffd8

Log:
Cache the images for a day

Changed paths:
  M  images/elephpants.php


Diff:
diff --git a/images/elephpants.php b/images/elephpants.php
index 88d4185..f957878 100644
--- a/images/elephpants.php
+++ b/images/elephpants.php
@@ -1,5 +1,21 @@
 <?php
 include_once $_SERVER['DOCUMENT_ROOT'] . '/include/prepend.inc';
+
+$now = $_SERVER["REQUEST_TIME"];
+if (isset($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
+    $last = strtotime($_SERVER["HTTP_IF_MODIFIED_SINCE"]);
+
+    /* Use the same logo for a day */
+    if (strtotime("+1 day", $last) > $now) {
+        header("HTTP/1.1 304 Not Modified");
+        exit;
+    }
+}
+$future = strtotime("+1 day", $now);
+$tsstring = gmdate("D, d M Y H:i:s ", $now) . "GMT";
+header("Last-Modified: " . $tsstring);
+header("Expires: " . date(DATE_RSS, $future));
+
 /*
 
  Simple script to serve elephpant images in json format.


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to