Drupal 7 cache page for anonymous users causes issues when loading different css files based on browser version
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.