Commit:    206aab8bf2a0fff87e5453eaeb4545bacd63ee36
Author:    Hannes Magnusson <[email protected]>         Fri, 6 Dec 2013 
17:00:35 -0800
Parents:   9098464a05bab5ebb92dfad27c7cee77e2663965
Branches:  master

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

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