NeilFawcett
3-11-05, 06:49 AM
If you link a style sheet into your document, does this always count as a hit?
There have been various opinions on taking some style sheets and moving them directly into the html page they were previously linked from. The idea of this is of course to reduce hits down, at the expense of a bit of bandwidth.
Now, can anyone confirm if this is actually a good move or not. ie: Where you have a link to a style sheet in an HTML document, will it always cause a hit to your website? ie: Or will caching prevent browsers from regularly "hitting" it?
*EDIT*
From some experiments, looking at apache logs on a test machine, I cannot see an access request for CSS files (unless you do a refresh on the browser). HOWEVER, I can see every image, and every javascript file included being accessed everytime!
Here's an example... First is a refresh, next two and just revisits back to the same page:-
[11/Mar/2005:10:56:39 +0000] "GET /style.css HTTP/1.1" 304 -
[11/Mar/2005:10:56:39 +0000] "GET /script.js HTTP/1.1" 404 296
[11/Mar/2005:10:56:39 +0000] "GET /mainlogo.jpg HTTP/1.1" 404 301
[11/Mar/2005:10:56:39 +0000] "GET /shared/yarrow.gif HTTP/1.1" 404 306
[11/Mar/2005:10:56:39 +0000] "GET /shared/bar_back.jpg HTTP/1.1" 404 308
[11/Mar/2005:10:56:39 +0000] "GET /main.html HTTP/1.1" 200 23744
[11/Mar/2005:10:56:39 +0000] "GET /shared/empty.gif HTTP/1.1" 304 -
[11/Mar/2005:10:56:39 +0000] "GET /shared/c-tl.gif HTTP/1.1" 304 -
[11/Mar/2005:10:56:39 +0000] "GET /shared/c-tr.gif HTTP/1.1" 304 -
[11/Mar/2005:10:56:39 +0000] "GET /cgi/poll/polls_image.gif HTTP/1.1" 304 -
[11/Mar/2005:10:57:06 +0000] "GET /script.js HTTP/1.1" 404 296
[11/Mar/2005:10:57:06 +0000] "GET /main.html HTTP/1.1" 200 23744
[11/Mar/2005:10:57:06 +0000] "GET /mainlogo.jpg HTTP/1.1" 404 301
[11/Mar/2005:10:57:06 +0000] "GET /shared/yarrow.gif HTTP/1.1" 404 306
[11/Mar/2005:10:57:06 +0000] "GET /shared/bar_back.jpg HTTP/1.1" 404 308
[11/Mar/2005:10:57:33 +0000] "GET /script.js HTTP/1.1" 404 296
[11/Mar/2005:10:57:33 +0000] "GET /main.html HTTP/1.1" 200 23744
[11/Mar/2005:10:57:33 +0000] "GET /mainlogo.jpg HTTP/1.1" 404 301
[11/Mar/2005:10:57:33 +0000] "GET /shared/yarrow.gif HTTP/1.1" 404 306
[11/Mar/2005:10:57:33 +0000] "GET /shared/bar_back.jpg HTTP/1.1" 404 308
This would surely imply:-
- Style sheets are better left linked - They will only be accessed (hit) first time.
- Somes images will cause a hit every time the page is shown. Why are some cached & others not??
- Every javascript will cause a hit every time the page is shown.
There have been various opinions on taking some style sheets and moving them directly into the html page they were previously linked from. The idea of this is of course to reduce hits down, at the expense of a bit of bandwidth.
Now, can anyone confirm if this is actually a good move or not. ie: Where you have a link to a style sheet in an HTML document, will it always cause a hit to your website? ie: Or will caching prevent browsers from regularly "hitting" it?
*EDIT*
From some experiments, looking at apache logs on a test machine, I cannot see an access request for CSS files (unless you do a refresh on the browser). HOWEVER, I can see every image, and every javascript file included being accessed everytime!
Here's an example... First is a refresh, next two and just revisits back to the same page:-
[11/Mar/2005:10:56:39 +0000] "GET /style.css HTTP/1.1" 304 -
[11/Mar/2005:10:56:39 +0000] "GET /script.js HTTP/1.1" 404 296
[11/Mar/2005:10:56:39 +0000] "GET /mainlogo.jpg HTTP/1.1" 404 301
[11/Mar/2005:10:56:39 +0000] "GET /shared/yarrow.gif HTTP/1.1" 404 306
[11/Mar/2005:10:56:39 +0000] "GET /shared/bar_back.jpg HTTP/1.1" 404 308
[11/Mar/2005:10:56:39 +0000] "GET /main.html HTTP/1.1" 200 23744
[11/Mar/2005:10:56:39 +0000] "GET /shared/empty.gif HTTP/1.1" 304 -
[11/Mar/2005:10:56:39 +0000] "GET /shared/c-tl.gif HTTP/1.1" 304 -
[11/Mar/2005:10:56:39 +0000] "GET /shared/c-tr.gif HTTP/1.1" 304 -
[11/Mar/2005:10:56:39 +0000] "GET /cgi/poll/polls_image.gif HTTP/1.1" 304 -
[11/Mar/2005:10:57:06 +0000] "GET /script.js HTTP/1.1" 404 296
[11/Mar/2005:10:57:06 +0000] "GET /main.html HTTP/1.1" 200 23744
[11/Mar/2005:10:57:06 +0000] "GET /mainlogo.jpg HTTP/1.1" 404 301
[11/Mar/2005:10:57:06 +0000] "GET /shared/yarrow.gif HTTP/1.1" 404 306
[11/Mar/2005:10:57:06 +0000] "GET /shared/bar_back.jpg HTTP/1.1" 404 308
[11/Mar/2005:10:57:33 +0000] "GET /script.js HTTP/1.1" 404 296
[11/Mar/2005:10:57:33 +0000] "GET /main.html HTTP/1.1" 200 23744
[11/Mar/2005:10:57:33 +0000] "GET /mainlogo.jpg HTTP/1.1" 404 301
[11/Mar/2005:10:57:33 +0000] "GET /shared/yarrow.gif HTTP/1.1" 404 306
[11/Mar/2005:10:57:33 +0000] "GET /shared/bar_back.jpg HTTP/1.1" 404 308
This would surely imply:-
- Style sheets are better left linked - They will only be accessed (hit) first time.
- Somes images will cause a hit every time the page is shown. Why are some cached & others not??
- Every javascript will cause a hit every time the page is shown.