PDA

View Full Version : Image caching - Cache-control: no-store, no-cache ...



AlexCz
08-03-2007, 09:31 AM
Hi,

I have created a simple page where I want to show automatically refreshed picture.
This picture still have a same name - sshot.jpg, but its content changes (it is output of other program which runs on a server).

So I setTimeout and in refresh function I have:
window.document.getElementById('sshot').src="sshot.jpg"

Problem is, that browser still show first loaded picture, even this picture changes over time.

I've googled that to prevent cacheing, there must be something like this in html:
<meta http-equiv="Cache-Control" content="no-store,no-cache, must-revalidate,post-check=0, pre-check=0,max-age=0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">

-it does not help, browser(ff) still uses first cached picture.

I found out, that if I disable memory cacheing using about:config by setting
browser.cache.memory.enable to 'false' then it works well. But it is not a way how to do it, I can not ask user to change setting of their browser. So I tried to add onload function where I do this:
user_pref("browser.cache.memory.enable",false);
-it also does not help...

So my question is - how can I prevent ff to cache image, how can i ask it "load image from disk, do not use cache" ?

jscheuer1
08-03-2007, 01:20 PM
function updateImage(){
var d=new Date().getTime();
document.getElementById('sshot').src='sshot.jpg?d='+d;
}
setInterval('updateImage()', 3000);