[web] [PHP/HTTP] Forcing Firefox to redownload an image
Firefox, as usual, decides to hold on to some graphs for dear life and never redownload them (I've had problems in the past with it holding on to CSS files, meaning that angry people complain that I haven't updated the styles they requested). *sighs*
Anyway, I thought this would be the fix:
# Set up the correct header:
header("Content-type: image/{$format}");
header("Pragma: no-cache");
header("Cache-Control: no-store, no-cache, must-revalidate");
This (unsurprisingly) works fine in IE. Firefox will not redownload the images, however. Is there any way to force it to do so?
I believe that your code causes Firefox only to not cache the HTML page, not the images/files which it is linked to. It is probably possible to set up your web server (assuming Apache) to output the header you just described so that all images/CSS files aren't cached.
Cheers!
Cheers!
I seem to remember that you need to do something like:
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="0">
or
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="Mon, 01 Jan 1990 00:00:01 GMT">
to get it to work in both IE and Mozilla/Firefox. However, I could be wrong as I don't have access to the page I did this with at the moment.
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="0">
or
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="expires" content="Mon, 01 Jan 1990 00:00:01 GMT">
to get it to work in both IE and Mozilla/Firefox. However, I could be wrong as I don't have access to the page I did this with at the moment.
Bah, sorry. I should have said - these headers are being sent by the image itself, (and hence the header("Content-type: image/{$format}");), and not by the page it is on. Meta tags wouldn't be of much use, in this case.
I can't remember... is there a Last-Modified header, or similar?
Edit: Apparently, there is. I can't tell you whether using it will make Firefox redownload the image, but you could try it.
John B
Edit: Apparently, there is. I can't tell you whether using it will make Firefox redownload the image, but you could try it.
John B
I use this:
Never failed me so far!
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");header("Cache-Control: no-store, no-cache, must-revalidate");header("Cache-Control: post-check=0, pre-check=0", false);header("Pragma: no-cache");
Never failed me so far!
Sander: I've seen that exact listing of headers before, but Firefox still ignores it. I've come up with an even easier solution - what this is is an image of a graph on a page that has the URL rewritten by some JavaScript as you select options in dropdown boxes and option buttons. I just stick ¤t_timestamp on the end of the URL which "stops" the image from staying in the cache as it is no longer seen as being the same image.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement