How to force client browser to download images from server rather using its cache

Posted by anonim.developer on Stack Overflow See other posts from Stack Overflow or by anonim.developer
Published on 2010-05-20T09:10:47Z Indexed on 2010/05/20 9:30 UTC
Read the original article Hit count: 133

Filed under:

Assume a simple aspx data entry page in which admin user can upload an image as well as some other data. They are stored in database and the next time admin visits that page to edit record, image data fetched and a preview generated and saved to disk (using GDI+) and the preview is shown in an image control.

This procedure works fine for the first time however if the image changes (a new one uploaded) the next time the page is surfed it shows previously uploaded image. I debugged the application and everything works correct. The new image data is in database and new preview is stored in Temp location however the page shows previous one. If I refresh the page it shows the new image preview. I should mention that preview is always saved to disk with one name (id of each record as the name).

I think that is because of IE and other browsers use client cache instead of loading images each time a page is surfed. I wonder if there is a way to force the client browser to refresh itself so the newly uploaded image is shown without user intervention.

Thanks and appreciation in advance,

© Stack Overflow or respective owner

Related posts about ASP.NET