view cache_check.inc @ 14:91ee5f49907e

Correct caching. We could probably push caching earlier, but more important that it is correct.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Wed, 19 Sep 2012 13:55:58 +0200
parents 6c0162497d56
children f51be7b9711a
line wrap: on
line source

<?php
function cache_check($mtime)
{
   if (DEBUG)
    var_dump($_SERVER);

  $HTTP_IF_MODIFIED_SINCE=$_SERVER['HTTP_IF_MODIFIED_SINCE'];
  $if_modified_since = preg_replace('/;.*$/', '', $HTTP_IF_MODIFIED_SINCE);

  $gmdate_mod = gmdate('D, d M Y H:i:s', $mtime) . ' GMT';

  if ($if_modified_since == $gmdate_mod) {
    header("HTTP/1.0 304 Not Modified");
    exit;
  }
  header("Last-Modified: $gmdate_mod");
}
?>