Sep 212009
Browsers are designed to think that Images with same name don’t change rapidly so regularly. This creates a problem in some cases where you have to reuse a specific name Or a specific location for a system.
One such case can be a social network which is designed in a way where the profile images are always:
http://www.mysite.com/users/images/user123/profile.jpg
Now, on changing this image, sometimes browsers don’t clear cache and thus show the last image. In Order to solve this, use a random number at the end of the image location and you will be able to see that image. as browsers will not cache it.
http://www.mysite.com/users/images/user123/profile.jpg?123
One method that I used is:
$stamp = time(); $imageLocation = 'http://www.mysite.com/users/images/user123/profile.jpg?'.$stamp echo $imageLocation
This should work.