OK. I think I solved it.
I've been messing around for the last hour or so.
Tried all sort of things which didn't work, so I continued building the overall application and ..BING.
The code I now have is as follows:
img.php (display image form DB)
Code: Select all
list($width, $height, $mimeType, $attr) = getimagesize($imgBlob);
header("Content-Type: ".image_type_to_mime_type($mimeType));
header("Cache-Control: max-age=86400, must-revalidate");
header("Content-Length: ".filesize($imgBlob));
echo $imgBlob;
As I'm building myself a application of extra ordinary magnitude, I've been adding my building blocks around the code.
One of these is the build header object. It includes:
imageCaller.php (Calls the image display script)
Code: Select all
header ("Cache-Control: cache, max-age=259200");
$offset = 60 * 60 * 24 * 3;
$ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
header($ExpStr);
header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
The above is now included in the header of the script that is calling img.php. This may have been the answer.
I know the caching times don't quite support each other, but it works.
Oh I think I do remember from way back that time zones can be a problem too.
I think the must-revalidate assists in renewing the cached file after the given time has expired and can be in the statement. It doesn't mean no-cache. The following document explains it better than I can.
http://www.mnot.net/cache_docs/
Why am I doing this?
Uhm, cause I can't seem to find a way to create temporary files from the web as I haven't worked out a way to enable a root process to change chmod(). Probably need to create a cgi or something. Another day.
And the images are only thumbs so they're not going to kill the mySQL cache on large queries...hopefully.
Hopefully some of this makes sense, as it's now 04:40 in the morning.