I've built a custom image gallery, integrated with a database.
all of the images are kept above the document root in a "media" directory (for security purposes); therefore, i am using a php script in the src attribute of the image tags to display the image in the browser.
to accomplish this, i chose to use the PEAR package "HTTP_Download", which worked great and performed fantastically on my staging server. I chose to use content-disposition inline, and set caching options on.
the problem, the images don't cache on a users machine. therefore, everytime the page is changed to display a new image, all of the thumbnails are downloaded once again...very annoying.
let me re-iterate, these files are not being generated on the fly, simply sent to the user via php.
here is an example of an image src attribute:
<img src="http://url.com/download/image?s=gt&id=2e7bea0eeb438cccb6232ec7d46cdc0c"/>
here are sample headers being sent to and from the browser:
Response Headers
Date Mon, 23 Jul 2007 19:15:33 GMT
Server Apache/2.2.4 (Win32) mod_python/3.3.1 Python/2.4.3 PHP/5.2.0
X-Powered-By PHP/5.2.0
Expires Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control public, must-revalidate, max-age=0
Pragma cache
Accept-Ranges bytes
x-sent-by PEAR::HTTP::Download
Last-Modified Sat, 21 Jul 2007 02:38:18 GMT
content-disposition inline; filename="37.jpg"
Etag "9c4ccc931266077ac50cbe1a6150c811-1783420111"
Content-Length 4206
Content-Type image/jpeg
Request Headers
Host kingthief.nak5.com
User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.5) Gecko/20070713 Firefox/2.0.0.5
Accept application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 300
Connection keep-alive
Referer http://url.com/gallery/?p=5751e61698d4d66fafaa8f0bb4f4926c
Cookie kingthief=mgcdn8ama8r4r4qeku1qjqpk70
If-Modified-Since Sat, 21 Jul 2007 02:38:18 GMT
If-None-Match "9c4ccc931266077ac50cbe1a6150c811-1783420111"
does anyone know of a good script that will cache images on a local browser in this way?
waiting for thumbnail re-loading everytime the page changes is just horrible...
thanks!
Al.