locked
Delete an image from user's cache? RRS feed

  • Question

  • User1000945240 posted

    I have a page where users upload images. The images upload fine. They go into a gallery of thumbnails and they appear correctly. An image can be selected from the gallery and a button clicked to open an image editor with the selected image. All working fine.

    The image can be manipulated in a few different ways and then saved to the server where it now appears in the thumbnail gallery. This too is fine.

    The user can select an image from the thumbnails and click another button to open it in image control. This is where things have been getting hairy.

    If the image was in the gallery's target folder and has not been edited when the page was first loaded then it opens fine in the image control. But if the image has been edited in the image editor and then chosen then the previous version of the image is loaded in the image control. The previous version NO LONGER EXISTS on the server as it was saved with the same name as the original. Yet the browser continues to show the original image.

    After many hours mucking about with my ajax settings I discovered that if I just rename the edited version of the file when it is saved after editing it can be selected and WILL load into the image control.

    I'm left with the conclusion that the original version of the image is somehow being loaded from the browser's cache.

    So is there a way to find it and delete it?

    Saturday, November 29, 2014 5:12 PM

Answers

  • User-821857111 posted

    You can't delete anything fro ma browser's cache, but you can force the browser to retrieve the image again by appending a querystring value to the url for the image. Usually, peeps add a timestamp:

    image1.ImagUrl = "/images/SomeImage.jpg?" + DateTime.Now.ToString();

    The browser sees a different value for the query string each time and treats the request as different, so won't show a cached version.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 30, 2014 5:59 AM

All replies

  • User-821857111 posted

    You can't delete anything fro ma browser's cache, but you can force the browser to retrieve the image again by appending a querystring value to the url for the image. Usually, peeps add a timestamp:

    image1.ImagUrl = "/images/SomeImage.jpg?" + DateTime.Now.ToString();

    The browser sees a different value for the query string each time and treats the request as different, so won't show a cached version.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 30, 2014 5:59 AM
  • User1000945240 posted

    Thank you very much.

    Sunday, November 30, 2014 12:37 PM