Welcome to WebmasterWorld Guest from 23.22.182.29

Forum Moderators: phranque

Message Too Old, No Replies

How to cache an image until browser closes?

     
7:07 am on Jun 24, 2010 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2886
votes: 1


On a particular site I have images which shouldn't be cached. On the other hand the images shouldn't be reloaded every time the visitor changes to another page on the site where one of those images is displayed, as long as the browser hasn't been closed in between.

Currently I am serving the following headers:

Expires: 0 
Cache-Control: private, pre-check=0, post-check=0, max-age=0
Pragma: no-cache


These headers work in that no version of the images is left on the disk, but the browser tries to reload them every time they are on a page, even within a single browser session. I am trying to emulate the behavior of cookies which are valid during the lifetime of the browser, but I haven't found the working combination of headers yet. Any idea's how I can achieve my goal?
9:41 pm on Oct 9, 2010 (gmt 0)

New User

5+ Year Member

joined:Oct 9, 2010
posts: 12
votes: 0


You can use for IE.

<meta http-equiv="cache-control" content="no-store" />

The Meta HTTP-EQUIV CACHE-CONTROL is specifically used by Internet Explorer.

The allowed values are:

* Public - may be cached in public shared caches
* Private - may only be cached in private cache
* no-Cache - may not be cached
* no-Store - may be cached but not archived
2:16 am on Oct 10, 2010 (gmt 0)

Senior Member from KZ 

WebmasterWorld Senior Member lammert is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 10, 2005
posts: 2886
votes: 1


Hi OceanSky,

Thanks for the hint and also welcome to WebmasterWorld!
I will certainly try the no-store cache option. It may be a good alternative for what I am using now.
10:04 am on Oct 13, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:Apr 30, 2007
posts:1394
votes: 0


If you use an application script to handle/output the images then you can setup a cookie or pass an id with the url to the script that handles the image based on session etc. Should work on all browsers but is more work.

If I understand right now you are setting up the header from the server for specific file types not via the application.