note 21144 deleted from ref.image by victor
| From: | victor@php.net | Date: | Mon, 09 Dec 2002 18:36:46 +0000 |
| Subject: | note 21144 deleted from ref.image by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40589@lists.php.net to get a copy of this message | ||
A post above mentioned using Cache Control headers to keep dynamically generated images from caching
in the user's browser. I've found that, with many browsers, this doesn't help--the
browser caches the image anyway.
The only way I've found to ABSOLUTELY ensure that an image is "fresh" is to put a
random GET argument in the URL. Since every call to the image has a new address, the browser
won't cache it.
Example:
print '<IMG SRC="MakeAnImage.php?r=' . rand(100000,999999) . '"
BORDER=0>';
If you're passing ACTUAL data in the URL, just tack a random attribute on the end.
Example:
print '<IMG SRC="MakeAnImage.php?data=' . $data . '&r=' .
rand(100000,999999) . '" BORDER=0>';
Easy to do, and guaranteed to work every time, on every browser.