[Zope] RE: zope/style sheets

Sam Gendler sgendler@impossible.com
Wed, 02 Feb 2000 16:53:41 -0800


>
>
> That was my thought, set a cookie once on the browser and use that to
> choose the style sheets and javascript files to load thereafter in
> that session.
>
> But your jeremiad on cookies & cahes makes me wonder.  Hobbling
> people's squids for such a trivial matter seems inhospitable somehow.
> Does Zope do anything special with cookies, like add a nocache tag to
> headers on cookied pages?
>

What I tend to do is have the mystylesheet.css file actually be a dtml-method that
can do the following.

Check the cookie, decide the appropriate path
Send a redirect to the client to a css file that DOES contain the correct data.

This way, the html page gets cached, all html files can include the same stylesheet,
and no caches get confused by caching the wrong object.  It aso makes it very easy to
add new options, etc.

Alternatively, create a dtml method that contains just two lines.  The first line
would contain
<dtml-call "RESPONSE.appendHeader('Cache-Control', 'proxy-revalidate')">
and the second line would contain the dtml code that includes the stylesheet based on
the user agent.

All pages that should contain the stylesheet code will then be served with a
proxy-revalidate header.  That header forces any network cache to send a
if-modified-since request, which should cause things to work correctly.  Some caches
might not handle it well, but most should (the ones I have had my hands on do...)

For industrial strength reliability, you could set cache-control: private, which
allows the browser cache (a private cache) to store the object, while any public
cache is not allowed to cache it.  I would be VERY surprised if any caches didn't
handle this correctly.

Both of these solutions seem easy to implement and maintain to me.  Let me know if
you have any questions

--sam

--
Sam Gendler
Chief Technology Officer - Impossible, Inc.
1222 State St. Suite 250
Santa Barbara CA. 93101
w: 805-560-0508
f: 805-560-0608
c: 805-689-1191
e: sgendler@impossible.com