Image cache problem

  • Thread starter Thread starter Bei
  • Start date Start date
B

Bei

I have a page which has to change 1 image inside periodically. However, I
don't have to modify the page to change. I just replace the old image file
with a new one with the same name.

Then there is a problem of that (images with same name). Everytime there is
a new image, the page still show the old image. Even refreshing the page
doesn't refresh that image. It's because the image name is the same and
browser just load it from the cache even I refresh. So I have to delete
"Temporary Internet Files" to view that image.

Is there a line of code that total disable caching? I have tried:
Response.AddHeader("Pragma", "No-Cache")
But that doesn't work for my case.

Thanks
Victor
 
you can have a special page to dispense your images, such as MyImage.aspx
then when you reference the image you can change the querystring slightly,
such as
<image url='MyImage.aspx?Dummy=1'>
<image url='MyImage.aspx?Dummy=2'>
etc.

This way the browser will see it as a new image each time and won't pull it
from the cache.
 
You can add a changing Query String to the URL for the image. This causes
the browser to download the image again, as the URL is different. You could,
for example, append a random number to your Query String, as in:

<img src="someImage.jpg?1">

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
 
Back
Top