Forum Moderators: not2easy

Message Too Old, No Replies

CSS caching query

         

driller41

1:55 pm on Jan 15, 2008 (gmt 0)

10+ Year Member



Hi, I am wondering, I have a global CSS file with the full design of my site - does the CSS file get downloaded once when a user first visits my site or does it get downloaded with each page view?

Many thanks

coopster

2:32 am on Jan 16, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That depends on the browser settings of the end user as well as the headers you send along with your documents. Typically, an end user will only want to retrieve it if it has been modified since the last time they requested it. So, if you send the appropriate headers and they have their browser set up optimally, you will likely send a site-wide CSS document once.

driller41

9:42 am on Jan 16, 2008 (gmt 0)

10+ Year Member



Thanks, I was under the impression that the default setting is to send the CSS file on the initial page download - it seems I am wrong - that sounds like a lot of wasted time to me if the CSS file is sent on each page view.

How do I set the headers the only send once, I am using .NET on IIS

coopster

2:30 pm on Jan 16, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



No, you are not incorrect. But the CSS still needs to be defined in every page that requires it, you HAVE to do that part on your end. It is the way the browser requests the file that makes a difference. You know how you can customize your browser settings to "check for newer versions of stored pages" in your internet browser settings panel? This is the first control feature. Most browsers will only request the page if it has changed. How does it know if it has changed? By the headers being sent back and forth.

A search over the forums here at WebmasterWorld turns up plenty of discussion on "css cache" such as this thread:
[webmasterworld.com...]