Hi folks.
I found strange issue with image server script.
The idea is to store images in the database (BLOB columns in mysql),
and to reference to them in such a way:
img src=http://www.site.com/images.php?op=header&sid=sessionid&rand=1234
In some reason I'm adding random parameter to this reference, to avoid caching.
Also, scripts issues no-caching headers
I don't like it but this is what client wants. However I think I may get rid of it, if needed.
Also, script issues no-caching headers:
Expires: Feb 1970 00:00:00 GMT
pragma: no-cache
Cache-control: no-cache
I'm giving this just to let you know all the details.
It works fine in LAN environment, but on production site sometimes it produces
broken images. I can't found reason of this. Could anybody help me ?
Is it related with caching ? I'm feeling it is something with HTTP headers, but not sure what exactly.
The script source:
<?php
include "$DOCUMENT_ROOT/../lib/somelib.php";
/ sqlget is a wrap around mysql_query() and mysql_fetch_row(),
always return 1 row
*/
list($image)=sqlget("select image from table where id='$id'");
header("Expires: Feb 1970 00:00:00 GMT");
header("pragma: no-cache");
header("Cache-control: no-cache");
header("Content-type: image/unknown");
echo $img;
exit();
?>
Things are working under Linux RH7.1/Apache 1.3.20/PHP4.0.4pl1/MySQL 3.23.37
Any suggestions are appreciated.
Thanks,
Max Rudensky.