|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is there anyway to keep someone's browser from caching an image... only? I know how to have it not cache the page, but I want only one image to be non-cached.
Any ideas? |
|
#2
|
|||
|
|||
|
I've never actually tried this, but I should imagine that it _may_ be possible through the use of a server module (e.g. a mod_perl module). As each item on the page is retrieved in a distinct GET request, it should be possible to return a different HTTP response header set for each request, meaning you could send back a no-cache pragma or expires value that is different for your particular image than the rest of the page. Problem is, capturing that particular GET request -- you may have to write a module to jump in at the URI translation stage and flag a special handler for the particular images you're concerned with.
I'll assume you're using Apache and know Perl , and will therefore be delighted to get to use mod_perl to try to do this. ;-) Go to http://perl.apache.org and have a dig through the mailing list archives. There's also an excellent mod_perl guide at http://perl.apache.org/guide, and if you don't find your answer there you can always subscribe to the list and pose a question -- a number of 'leading lights' in the mod_perl community are there to help out. If you're not using Apache take a look at your server docs and see if you can write modules to get inside and play around with all the important bits. Oh, and good luck. And be sure to post about any success you have -- I'd be quite interested in having some kind of reusable module to do that stuff. Perhaps something that took a list of images from a file or DB and prevented caching on them... [This message has been edited by christucker2 (edited August 09, 2000).] |
|
#3
|
|||
|
|||
|
I know how to use mod_perl/Apache/*nix server and perl. I wasn't looking for something like that though :P. I'm just want a tag to stick in the HTML... if there isn't one, I don't care.
|
|
#4
|
|||
|
|||
|
Heh, there isn't one. But go on. You _know_ you really want to develop that module. Don't you? Come on.... ;-)
|
|
#5
|
|||
|
|||
|
To prevent someone from caching an image (or any other web resource), you need to set the appropriate http headers. This is not achieved by doing anything in the enclosing page, but instead is something that (usually) the web server has to do for you.
In apache, a simple way to set expiration times (say, to a month if it is long-term cacheable, or to 0 if it is not) is to use an .htaccess file containing an ExpiresActive and one or more ExpiresByType directives. See the apache docs for details. ------------------ WEB CACHING RESOURCES: http://www.web-caching.com/ |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > no-cache |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|