[web] [PHP/HTTP] Forcing Firefox to redownload an image

Started by
5 comments, last by benryves 18 years, 7 months ago
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?

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

Advertisement
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!
- fyhuang [ site ]
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.



---CyberbrineDreamsSuspected implementation of the Windows idle loop: void idle_loop() { *((char*)rand()) = 0; }
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.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

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
The best thing about the internet is the way people with no experience or qualifications can pretend to be completely superior to other people who have no experience or qualifications.
I use this:

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!

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

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 &current_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.

[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]

This topic is closed to new replies.

Advertisement