IE8 Compatibility View & Intranets: Specify X-UA-Compatible as a http header, not meta tag.
I develop web applications at work for internal consumption. Like many big companies, the company I work for happens to use Windows as the standard OS for thousands of employees. With Windows comes Internet Explorer, and with it come web development hassles.
As background, Internet Explorer used to be pretty terrible at rendering web pages according to web standards. With IE8, Microsoft stepped up and improved its behavior substantially. However, Microsoft was worried that all the existing sites and web applications designed to its previous quirks would break horribly, and so they added a mode called "Compatibility View". If a (poorly-implemented) site looks bad under IE8, the user can turn on Compatibility View and see the site rendered as versions of yore used to display it. Fine by me.
Microsoft further realized that (in general) all the web "enterprise" applications that big companies tend to host on their intranets tend to be bloated crap designed by clueless developers targeting Microsoft only and designed to only work in old versions of Internet Explorer. So they decided to ship an option with IE8 that says "Every computer that happens to be on my intranet cannot be trusted, so display the whole lot of them using Compatibility View." And then Microsoft decided to turn that on by default.
The upshot of this means that if you develop web applications at work for internal consumption, the browser of almost every employee is set (by default) to display your work using old, broken techniques that are incompatible with all other modern browsers. Nice one, Microsoft.
Now, for the modern web developer Microsoft provides a mechanism for saying "Hey, trust me, this web page is built properly. Let go of your horrible heritage and embrace the future." As they show on their site, all you have to do is put the
<meta http-equiv="X-UA-Compatible" content="IE=8" /> in the head of your page and all will be kittens and rainbows and unicorns. However, as I discovered today:
This meta tag does not override the "Display intranet sites in Compatibility View" setting.
After two (more) hours of my life were stolen by IE, I found the answer buried in a discussion on MSDN. If you want your web application to tell IE8 to really, really, really trust you, you need to instead send
X-UA-Compatible as an HTTP header from your web server.
Because I happened to be using Apache as my reverse proxy when I was fighting and found this solution, here's a link to a blog entry on how to send this header using Apache.
Thanks for the HTTP header tip, finaly my website works correctly !