Forum Moderators: open
After hearing how browsers cache stylesheets, using either the <link> or @import procedure, I decided I'd like to look into caching more of my site.
For instance, I have an identical header and footer on most of my pages. The code is exactly the same on each and every page. Thus, there's really no need for the browser to take time to download that code page after page.
I thought about using SSI, but then remembered that those files are done at the server level and the browser never knows they exist. So I guess an SSI file won't be cached.
I have no other ideas for caching that code, however. Does anyone else know a way?
Also, my header and footer include rotating banners. I can call them with an SSI, but the way I see it, that may complicate things since the banner portion of the header and footer will be different for each page.
I haven't seen this addressed anywhere else - would love to see some discussion on the topic though!
As you have surmised, SSI is treated as part of the page, and not as a separate, cacheable entity. External JavaScripts are cacheable, but then you run into the problem of user-agents and robots which do not support JS, or users who have disabled it.
Except for external client-side scripts, external stylesheets, and shared images, you basically have to think of browser caching at the page level.
Here's a decent caching tutorial [mnot.net], with a link to a useful cacheability checker script.
Jim
I'd think that you would get more mileage out of PHP from the basic stuff I have read about it.
with regard to SSI do a search for XBitHack in this site - jdmorgan has already written some great stuff about it. as for PHP and headers, if you are interested there are quite a few posts about this in the current php forum.
probably the easiest way to reduce the ammount of code sent to the browser is by emplying the apache module mod_gzip. this can compress html code up to 80% - so you get a page which normally contains 20 kb of html code, this is compressed down to 3 or 4 kb. this makes for great savings on download times - especially on big weighty html pages with lots of text.
be aware that mod_gzip'ing all your pages before sending them to the browser needs more CPU resources. e.g. i have had to turn it off for all pages under 15 kb on our server, as it brought our server to its knees (we have a 2.2 ghz cpu and serve 100,000 pages a day)