IE6 Caching and mod_rewrite-ing

  • Thread starter Thread starter dirkgomez
  • Start date Start date
D

dirkgomez

Here's the requirement: depending on a cookiee setting documents shall
be delivered with different CSS style sheets.

Here's how I solved it so far: I have a .htaccess which looks like
this:

RewriteCond %{HTTP_COOKIE} stylesheet
RewriteRule ^css/portal.css css/bw_portal.css [L]

So if the cookie stylesheet is set portal.css is automagically
rewritten to bw_portal.css.

This works most of the time - the less aggressive IE's caching the
better. Proxies may come in the way as well.

For CSS files I send this http header to prevent proxy caching (via
mod_headers)

Header Set Pragma "no-cache"

The page whose css gets rewritten sends these metatags:

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="cache-control"
content="no-cache,no-store,must-revalidate">
<meta http-equiv="Expires" content="-1">

All this is supposed to say: always ask the server for the document,
still "randomly" IE choosess to use the wrong stylesheet. Is appending
a unique string to the URL the only way to force IE to really look at
the content?

-- Dirk
 
Here's the requirement: depending on a cookiee setting documents shall
be delivered with different CSS style sheets.

Here's how I solved it so far: I have a .htaccess which looks like
this:

RewriteCond %{HTTP_COOKIE} stylesheet
RewriteRule ^css/portal.css css/bw_portal.css [L]

So if the cookie stylesheet is set portal.css is automagically
rewritten to bw_portal.css.

This works most of the time - the less aggressive IE's caching the
better. Proxies may come in the way as well.

For CSS files I send this http header to prevent proxy caching (via
mod_headers)

Header Set Pragma "no-cache"

The page whose css gets rewritten sends these metatags:

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="cache-control"
content="no-cache,no-store,must-revalidate">
<meta http-equiv="Expires" content="-1">

All this is supposed to say: always ask the server for the document,
still "randomly" IE choosess to use the wrong stylesheet. Is appending
a unique string to the URL the only way to force IE to really look at
the content?

-- Dirk

I don't really see why you're doing any of this server side.
You set the preference in a cookie using javascript.
When the page loads, you set the stylesheet by looking at the cookie.
 
Back
Top