Search code examples
htmlbrowserbrowser-cacheimage-caching

Is there a way to force browsers to refresh/download images?


I have a problem where users are reporting that their images aren't being uploaded and the old ones are still there. On closer inspection the new images are there, they just have the same name as the old one. What I do on the upload is that I rename the images for SEO purposes. When they delete an image the old index becomes available and is reused. Therefore it has the same image name.

Is there a way to (i thought maybe there might be a meta tag for this) to tell the browser to not use its cahce?

The better answer is to rename the image to something totally new. I will get working on that but in the mean time is the quick solution while I work on the bigger problem.


Solution

  • Append a query string with an arbitrary unique number (or time, or version number, etc.):

    <img src="image.png?80172489074" alt="a cool image" />
    

    This will result in a new request, because of the different URL.