Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Caching problem - I think!

Status
Not open for further replies.

Denster

Programmer
Apr 9, 2001
198
GB
I have an image button that displays an image the user uploads using the fileupload control. The upload works fine and I can see the file in the correct place, however the image on the button doesnt refresh. I have tried Page.Request.Url.ToString() but this doesnt seem to do anything. Even if you click out of the page and go back in still displays the wrong image. The only way I can get it to display the correct image is to physicaly press the refresh button in the browser. Sounds like a caching problem, any ideas?
 
Page.Request.Url.ToString()
just returns the string of the url.

what do you mean it displays the wrong image? if you want to change which image is displayed change the source of the image control.

if you mean you overwrite the file with a new image, but it's not updated, then you may need to add page headers to not cache the page, or image, or something of that nature. I haven't had to do this in any of my projects. if you need to go this route google "http headers don't cache image".

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I'll try and be a bit more specific.
My image button has a source image for example - ButtonImage.jpg in a specified folder. I have an upload control that can upload another image if required, replacing ButtonImage.jpg. The image on the image button still shows the old image until the refresh button on the browser is pressed. In the mean time I will check out the "http headers don't cache image" sugestion and see what I can find.
 
since your using the same image name you will need to use some header tag to not cache the images. This may add noticable latency for the page because the page will always pull images from the server instead of pulling them from the local cache.

another option might be to disable viewstate for the label button. This is just a guess.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Dont know if this confuses things a little but I am also using master pages for my site. It looks like the header section is part of the master page so putting anything in here will affect the whole site and not just the page I am having difficulty with. Setting the viewstate to false didnt work either.
 
master page doesn't matter.
you can add a header via Page.Headers.Add(); or Response.Headers.Add(); or something like that.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I've just tried something else. I thought maybe something like "Do Events" in VB would work so I put "Threading.Thread.Sleep(100)". Its probably a horrible way of doing it but it looks like its working.
 
Spoke too soon. This works locally on my PC but still shows the old image when I upload to the server. I'll have another look at the header idea.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top