IIS 7 has improved and simplified support for GZip encoding enabled out of the box and for the most part it seems to be working well on my Vista install. I see my CSS and other text content properly GZip encoded. IIS 7 also allows you to encode dynamic content easily which is nice because that was a real bitch to set up in IIS 6.
Compression is configured in IIS 7's ApplicationHost.config file (C:\Windows\System32\inetsrv\config\applicationhost.config) and there's a simple httpCompression section that seems to be pretty self explanatory. Here's what I have set up:
<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
<scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
<dynamicTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</dynamicTypes>
<staticTypes>
<add mimeType="text/*" enabled="true" />
<add mimeType="message/*" enabled="true" />
<add mimeType="application/x-javascript" enabled="true" />
<add mimeType="*/*" enabled="false" />
</staticTypes>
</httpCompression>
and
<urlCompression doStaticCompression="true" doDynamicCompression="false" />
I think doStaticCompression is the default and doesn't need to be set, although I couldn't get any JavaScript to compress until I added this (but other content did). doDynamicCompression needs to be explicitly enabled although frankly I'm not sure that I'd want that set on all dynamic content.
Notice that unlike IIS 6 where you would map application extensions, IIS 7 uses Mime Types which seems like a better solution for applying compression globally. httpCompression settings are ApplicationHost specific and can't be inherited in lower levels. urlCompression can be moved to child Webs/virtuals but it's disabled by default:
<section name="urlCompression" overrideModeDefault="Deny" />
JavaScript No Workey
As I mentioned static compression seems to work on any text documents (static htmltext, xml and css), but I'm getting no consistent love at all from static javascript content loaded from various applications. In requests to complex pages I see my CSS compressed but not all of my JavaScript is compressed.
For example, I'm using FCK Editor and have some ASP.NET code that loads up a the FCK Editor on a page with the JavaScript as static script src attributes loaded into the page. What's odd is that some .js content compresses but some other does not:
In fact none of the FCK subdirectory content is compressing which is odd.
Is it possible there's some sort of restriction for directory level depth that might be a problem here? File name conflicts?
I mentioned I had similar issues like this on IIS 6 with compression where nothing in APP_THEMES would compress. That thankfully works in IIS 7 now but this behavior I'm now seeing with FCK sure looks like a similar situation.
I ran into a somewhat cryptic message here that describes some of the inner details of the compression implementation. One of the things that's interesting is that IIS 7 will not cache any dynamic content that's compressed in the kernel cache, which means if the server has to recompress content. I'm not sure if this is a great solution to have based on generic content types. I think for situations like this it will be better to dynamically compress only when it's necessary rather than taking the hit of wholesale compression for every hit. In ASP.NET applications doing 'manual' Gzip compression is pretty easy as I showed in this post a while back.
For the moment though I would like to figure out WTF some content won't compress <s>. Anybody running Longhorn Server and seeing if this behavior is different?
Other Posts you might also like