1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Cache the images for a day

This commit is contained in:
Hannes Magnusson
2013-12-06 17:00:35 -08:00
parent 9098464a05
commit 206aab8bf2

View File

@@ -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.