I am building a site in php. I was trying to allow users to change their profile image. But in internet explorer new image is not showing up..IE still shows old image. It will show new image only if I close and open the browser. URL for this image is always same. How do I invalidate IE cache,,,"Cache-Control: no-cache" is not working.
A:
One garanteed way you could do that is to rename the image everytime its uploaded (assuming you keep the file name in some sort of database). So since the image name always changes ie(or any browsers) will redownload it everytime.
Iznogood
2010-07-31 00:21:46
+1
A:
depending on how often you need your image updated, whether it be once or many times you can set some jscript up to load the image src = http://imgurl.jpg?randomnumber and that will refresh your image, you just then put it on a timer in your jscript, and you use the onload and on error events. best part is none of the images need to be renamed, you need to simply draw a new random number with your jscript and reload the url for the image
Jim
2010-07-31 00:22:49
What is so bad with renaming the image? Its often obligatory if many users upload the same image name. Pretty standard stuff no?
Iznogood
2010-07-31 00:37:24
well for example, if you can get away without renaming an image you save yourself some work, for instance with a webcam app that just overwrites the old image, the webbrowsers wont update because to them its the same image, throwing in a random query with your image url will force the browsers to update the content, if you rename the images, you then have to update your display code every time to account for the name change
Jim
2010-07-31 21:20:26