Search code examples
optimizationpageloadimage-loadingpage-load-time

Loading the same image in different urls


I have an image loaded in a web page say http://example.com/test.jpg on example.com

Now, say if, via a hyperlink on that page, the user goes to example.com/testpage.html where the same image is present (with src http://example.com/test.jpg), then would the browser request that image from the server again?

P.S.: The problem I am facing is slow page rendering on a single html page due to lots of images & javascript. So I plan to load some images on the previous referrer url so that when the user enters the page, some images have already been loaded. Note that I do not plan to load the page asynchronously via js/ajax. I want to do a simple redirect to the given page & want some images to be already loaded.


Solution

  • As long as the domain is the same, and your caching is set up normally, the browser will make a request, but get a 304 Not modified response, and not need to re-download the entire asset again.