English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am doing some image manipulation on users' inputs: everytime, the image is modified, but is sent by the server with the same name (can't change it).
Putting headers such as:
header("ETag: PUB" . time());
header("Last-Modified: " . gmdate("D, d M Y H:i:s", time()-1) . " GMT");
header("Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT");
header("Pragma: no-cache");
header("Cache-Control: max-age=0, s-maxage=0, no-store, no-cache, must-revalidate");
BEFORE the tag works fine with IE6-7, but fail with Firefox: the image on the screen is the image cached on the user's machine.
Any idea how to implement this so it can run on firefox?

2007-09-15 21:55:15 · 3 answers · asked by just "JR" 7 in Computers & Internet Programming & Design

Gyuri: nope! (ok IE6-7, no on FF)

2007-09-15 22:07:11 · update #1

3 answers

As far as I'M aware, you cant, its is done by the browser to save repetitive calls to the server, unless you are dynamically generating the images, the browser will cache images.

2007-09-15 22:27:29 · answer #1 · answered by cheek_of_it_all 5 · 0 0

You say you're putting the code above before the tag. I assume this means you're placing them in the file that generates the HTML code containing the image tag (IMG), right?

If so, you're doing it wrong - this only makes the HTML code uncacheable, not the image.

There are two possible solutions of the top of my head :

1) If your image manipulation script outputs the image directly (as opposed to storing it in a file somewhere), put the no-cache code in that script.

2) If the manipulated image is saved to disk (so the file is changing all the time), it's going to be more complex. You can either prevent caching using .htaccess -
http://www.askapache.com/htaccess/using-http-headers-with-htaccess.html#prevent-caching-with-htaccess

....or modify your setup so that you have a PHP script displaying the image, e.g. use something like in your HTML, where image.php contains the anti-caching code and readfile('image_file_here.jpg') to output the image.

2007-09-19 10:00:40 · answer #2 · answered by White Shadow 1 · 0 0

This single line must be enough:
header("Cache-Control: no-store, no-cache, must-revalidate");
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.

Update: Perhaps you should try it on an other computer with Firefox, you might have just misconfigured something in your FF. (Honestly, I can't imagine anything which can cause an exception like this.)

2007-09-16 04:59:44 · answer #3 · answered by Gyuri 2 · 0 0

fedest.com, questions and answers