[thelist] Cache Tutorial (was: Is server-side browser-sniffing a bad idea?)
Matthew Blanchard
blanchardmatthew at hotmail.com
Thu Dec 6 18:16:30 CST 2001
> > > I've read recently that using server-side browser-sniffing to keep
> > > code lean by tailoring it for each browser's quirks is NOT
> > a good idea
> > > because of web caches. The undesirable scenario is that a web cache
> > > stores the page designed for WinMSIE5 (e.g.) and then delivers THAT
> > > verison when requested by a user with MacNN4... resulting
> > in a layout
> > > mess for that particular user.
I recommend reading this cache tutorial:
http://www.mnot.net/cache_docs/
1. Using <meta http-equiv="Pragma" content="no-cache"> is wrong.
2. You can send a "Cache-Control: no-cache, must-revalidate" and/or Expires
HTTP header.
3. This technique causes a subtle problem with dynamically generated CSS
files (see previous discussion): the browser will download the CSS on every
page (I think so. I haven't tried that actually), and the user will have to
wait a bit.
I suggest working with sessions: change the link to the CSS file to:
<LINK href="my_browser_sensitive_css.asp?<%=Session.SessionID%>"
rel="stylesheet" type="text/css">
Now, in "my_browser_sensitive_css.asp" don't use "cache-control: no-cache".
On the contrary: let the proxy/browser cache this page.
That way each user has a uniqe URL to the CSS file, and each version is
stored in the cache.
More information about the thelist
mailing list