Replacing images with the same name in folders

A.) When I use the code to delete, say image 123.jpg in the Pics folder and I load another image and rename this image also Image123.jpg and put it in the Pics folder for some reason a new image appears, but it uses the dimensions of the image I'm deleting. Using the repeater here to display the image .................

B.) When I just copy and run, tell Image99.jpg to my Pics folder that all the pre-made ones contain Image99.jpg, then of course it changes the original one. So for some reason it has to get cached because when I run my page it still shows the first image. Using normal picture control here ................

Why does it do A and B ........ and how can I get around it ..... Problem A is more important to me because I need to change the names of the images when the user clicks on the Change Logo button.

0


source to share


2 answers


The browser caches images, so if you are replacing an image, you need to change the url that is requesting the image to see the new image.

You can do this either:



  • Change the name of the image itself.

  • Add a request to the url you are changing.

If you add the version number to the url eg. images/Image123.jpg?version=42

and increment the version number when replacing the image, the browser will request a new image from the server as the browser caches files based on the full url, not just the filename.

+3


source


If it is a caching issue, you can do the following.

Program:

Response.Cache.SetCacheability(HttpCacheability.NoCache);

      



Declaratively:

<%@ OutputCache Location="None" VaryByParam="None" %>

      

By caching web pages, you avoid re-generating information about subsequent requests, so keep in mind that this can negatively impact page load times as caching will be disabled.

+1


source







All Articles