Search code examples
javascriptimagehttpcachingreload

page reload and image caching


I find out that whenever I do window.location.reload(), the requests for the images on my web page is sent to the server. The images are cached with an expiry date, thus I think they should be loaded from cache instead. Because all I get from the server is 304 unmodified, I have a lot of images on the page so I don't want a request for each image when the page refreshes.

My question is why is the browser try to contact the server instead of loading them from cache?

Thanks!


Solution

  • 304 Not Modified indicates to the browser that it should reload from cache. If you look at the bytes sent it should be less than 1kb when reloading from cache.