Flushing image from database to browser - how to get it cached??

From: Date: Mon, 23 Dec 2002 07:35:07 +0000
Subject: Flushing image from database to browser - how to get it cached??
Groups: php.general 
Request: Send a blank email to php-general+get-129147@lists.php.net to get a copy of this message
Hi all, I'm storing a bunch of images in a MySQL database. I use a small PHP script to load the appropriate image from database and flush it to the browser. Because this script flushes in content-type image/jpeg (or similar) it can be used as IMG SRC. So images can be shown on a webpage using the following HTML: <IMG SRC="image.php?id=2"> This works perfectly fine but the browser (IE) does not cache these images. On one hand I do understand why -- the image source is a script, not a static image file, so the browser qualifies the resulting content as dynamic. On the other hand though: in my setup image.php?id=1 is (as good as) eternally the same image and for image.php?id=2, image.php?id=3, etc. the same thing. So it would be no problem if the browser would cache f.e. image.php?id=1 as if it is a static image. It would even be desirable because it saves bandwidth. So actually the issue is: how can I get browser to cache image.php?id=1 (... etc.) just as it caches image1.jpg (... etc.)?? The only thing I've thought of is using mod_rewrite to rewrite URI's like image1.jpg into image.php?id=1 but I haven't tried it yet -- don't know if it's a logical idea. Thanks in advance, Tim Molendijk

« previous php.general (#129147) next »