TigerTiger
TigerTiger

Reputation: 10806

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

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

Upvotes: 3

Views: 1329

Answers (6)

Stevko
Stevko

Reputation: 4485

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.

Upvotes: 0

jcoder
jcoder

Reputation: 30035

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

Upvotes: 0

chelmertz
chelmertz

Reputation: 20601

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.

Upvotes: 1

Igor ostrovsky
Igor ostrovsky

Reputation: 7392

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.

Upvotes: 2

Tim Martin
Tim Martin

Reputation: 3697

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).

Upvotes: 3

Nick Fortescue
Nick Fortescue

Reputation: 44153

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

Upvotes: 2

Related Questions