note 21144 added to ref.image

From: Date: Tue, 30 Apr 2002 19:32:40 +0000
Subject: note 21144 added to ref.image
Groups: php.notes 
Request: Send a blank email to php-notes+get-30024@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. -- http://www.php.net/manual/en/ref.image.php http://master.php.net/manage/user-notes.php?action=edit+21144 http://master.php.net/manage/user-notes.php?action=delete+21144 http://master.php.net/manage/user-notes.php?action=reject+21144

« previous php.notes (#30024) next »