R – IIS7 Compression Failure

httphttp-compressioniis-7

I'm having issues with IIS7's static compression. I've read some of the other posts, and I'm out of options. Here's what I have:

In the applicationHost.config, I've set up:

    <httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files" staticCompressionDisableCpuUsage="100">
        <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" staticCompressionLevel="9" />
        <staticTypes>
            <add mimeType="text/*" enabled="true" />
            <add mimeType="message/*" enabled="true" />
            <add mimeType="application/x-javascript" enabled="true" />
            <add mimeType="*/*" enabled="true" />
        </staticTypes>
    </httpCompression>

The "enable static compression" checkbox is enabled for my site.

I get a big fat uncompressed file when I load up the site. If I look at the request headers, I see:

Accept-Encoding : gzip,deflate

but, in the response, I get:

Content-Type: application/x-javascript

Last-Modified: Fri, 10 Jul 2009 01:13:41 GMT

Accept-Ranges: bytes

Etag: "3be6da9fb0ca1:0"

Server: Microsoft-IIS/7.0

X-Powered-By: UrlRewriter.NET 2.0.0, ASP.NET

Date: Fri, 10 Jul 2009 03:39:35 GMT

Content-Length: 81515

Anyone have any ideas what I'm doing wrong here?

Also, FWIW, I'm running in Integrated, not "Classic" mode.

UPDATE: I got it working, but I'm not sure why it works now. All I did was enable dynamic compression for the site, and everything started working. Anyone have any thoughts?

Best Answer

I was having the same problem and I believe it is because we are using UrlRewriter.NET. While it is enabled all file requests are routed through the handler to determine whether they should be url rewritten or not. This changes a css or js file into a dynamic request instead of static, therefore GZip compression seems to not work in IIS7 until you check the dynamic content compression box. That's my theory anyway...

Related Topic