2

If you have "cache page for anonymous users" on and are using server logic(http_user_agent) to load different css based on the browser version, that logic will not fire and you will get the css that was cached from the last visitor. This seems as if this will also cause some issues when loading js and css based on browser version and for responsive design...more specifically to browsers that don't understand media queries....pre IE 9 browsers. Does anyone have any solution on a work-around for using anonymous cache and loading the correct css based on server logic?

2

Serving up different content based on request headers isn't the best idea in general, especially if you aren't sending back a Vary header.

The best workaround is to use markup rather than server side logic. When you do this, Drupal will cache things properly.

For IE, this means either using HTML conditionals and/or Paul Irish's method and/or JS "cleanup".

Pre-IE9 support for media queries has a few popular solutions, including the the Respond library.

For Drupal, I would recommend using a HTML5-aware base theme like Omega, which wraps all of this up in a nice package.

2
  • thanks. I used the conditional module and added the IE conditions for the specific css in the .info file for the theme. I'm using the pixture_reload theme (adaptive theme) Everything works perfectly with anonymous cache on. – jon Mar 13 '12 at 1:04
  • Glad this helped. If you think this is a good answer, and it indeed answered your question, then you should accept it (click the checkbox to the left of the answer). That will help build your reputation here when you come back. – mpdonadio Mar 13 '12 at 1:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.