I have a class for caching some images
<?php
class Vp_CacheImage
{
public function cache($cacheTime, $place) // $place = id of image (between 1 and 100)
{
$send_body = true;
$etag = '"' . md5(date('d.m.Y', time()) . $place) . '"';
header("ETag: " . $etag );
header("Last-modified: " . gmdate("D, d M Y H:i:s", $cacheTime) . " GMT");
$inm = explode(',', getenv("HTTP_IF_NONE_MATCH"));
foreach ($inm as $i)
{
if (trim($i) == $etag || trim($i) == $cacheTime)
{
header ("HTTP/1.0 304 Not Modified");
$send_body = false;
}
}
if(getenv("HTTP_IF_MODIFIED_SINCE") == gmdate("D, d M Y H:i:s", $cacheTime). " GMT")
{
header ("HTTP/1.0 304 Not Modified");
$send_body = false;
}
header("Expires: " . gmdate("D, d M Y H:i:s", time() + Config::$config['cache']['images']['topvideo']) . " GMT");
header("Cache-Control: max-age=" . Config::$config['cache']['images']['topvideo'] . ", must-revalidate");
if ($send_body) return true; else return false;
}
}
It works. But I have to make a picture reloaded sometimes, and not taken from cache. How to do it?