Image cache problem

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
 
S

Steve C. Orr [MVP, MCSD]

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.
 
K

Kevin Spencer

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top