I'm trying to force the browsers to cache the images I'm displaying through a PHP script.
So far, I have this... and it's not quite working. For some reason the browser will redownload them every couple times, instead of every 3 days:
(BTW, ob_get_contents() holds the image data.)
Code:$expires = 60 * 60 * 24 * 3; $exp_gmt = gmdate("D, d M Y H:i:s", time() + $expires )." GMT"; $mod_gmt = gmdate("D, d M Y H:i:s", time() + (3600 * -5 * 24 * 365) )." GMT"; @header("Content-type: image/jpg"); @header("Content-Disposition: inline; filename=purrun.jpg"); @header("Expires: {$exp_gmt}"); @header("Last-Modified: {$mod_gmt}"); @header("Cache-Control: public, max-age={$expires}"); @header("Pragma: !invalid"); @header("Content-Length: {$size}"); @header("ETag: " . md5( ob_get_contents() ) );
Anyone mind giving me a hand? Thanks.



Reply With Quote
). There are a few minor issues, though. Some may have an effect, some certainly won't.
Bookmarks