Multiple displays of the one image file on a web page = multiple http requests to the same file?

StackOverflow https://stackoverflow.com/questions/1443250

  •  22-07-2019
  •  | 
  •  

Question

If I display abc.jpg 20 times on a web page, does loading of the web page cause 20 http requests to the abc.jpg? Or it depends if I am using relative or absolute paths?

Thanks

Was it helpful?

Solution

It's down to the browser. A poorly written browser may request the same file multiple times, but any of the widely-used browsers will get this right. It shouldn't matter whether they are using relative or absolute paths (though mixing between relative and absolute paths on the same page might trip up some browsers, so you should probably avoid it).

OTHER TIPS

It depends on the web browser, but any modern browser should only request it once.

It is up to the browser. A modern browser will try hard to cache the image. Use consistent URL format in your requests when possible - consistent capitalization, don't use "www." one time and no "www." another time, etc.

Download Firebug and use the 'Net' tab to inspect all requests.

For this case, I agree with the other answers, any modern browser with proper settings should cache it.

It does depend on the browser settings but it also depends on what the web server tells the client to do with the image.

See this, it's quite complicated http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html

While I agree with the above statements, I suggest looking at your web server access log for the target image and comparing the referring page and browser fingerprint.

You will possibly see lots of hits to HEAD rather than GET in order to make sure the file cache is up to date.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top