Furqan Hameedi
Furqan Hameedi

Reputation: 4400

IIS 7 HttpCompression Not Working

I am using following web.config block to enable static and Dynamic Compression on IIS7, but its not compressing the response.(Verified it through Fiddler)

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files">
     <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" />
     <dynamicTypes>
           <add mimeType="text/css" enabled="true" />
           <add mimeType="message/*" enabled="true" />
           <add mimeType="application/x-javascript" enabled="true" />
           <add mimeType="*/*" enabled="true" />
     </dynamicTypes>
     <staticTypes>
           <add mimeType="text/css" enabled="true" />
           <add mimeType="text/javascript" enabled="true" />
           <add mimeType="message/*" enabled="true" />
           <add mimeType="application/x-javascript" enabled="true" />
           <add mimeType="*/*" enabled="true" />
     </staticTypes>
</httpCompression>
 <staticContent>
    <remove fileExtension=".js" />
    <mimeMap fileExtension=".js" mimeType="application/x-javascript" />
</staticContent>

Yet it is not doing any compression. I had also check the server has static/dynamic compression installed.also tried this how-can-i-get-gzip-compression-in-iis7-working but not working for me. Can anyone help with something new?

Upvotes: 2

Views: 2949

Answers (2)

Luke Puplett
Luke Puplett

Reputation: 45135

I had trouble with getting it working by following snippets of advice on StackOverflow. Here's how I managed it.

First, ensure Dynamic Compression is installed as a feature of the Web Role. Normally, you get a warning in IIS Manager if the module is not installed, but you won't if you've set the web.config manually since it tricks the IIS UI logic.

I then removed all the web.config stuff (as in your question) and set it via the IIS Manager. I did this because on MSDN, an easily-missed comment says:

You can also add wildcard entries for the MIME types. However, you can set MIME types for the web server level only. For example, to enable static compression for all MIME types for the default website, first add wildcard entries for the MIME types for the server level, and then enable static compression for the default website.

Focus on:

However, you can set MIME types for the web server level only.

So I'm not sure whether all those filters and things really work in the web.config. Personally, it didn't for me - i.e. no Content-Encoding: gzip header.

After I took it all out I had to use IIS Manager, under IIS: Compression, to ensure it was set at the server level and then for the site, I had to remove the tick, apply it, tick it again and reapply it.

I ended up with just <urlCompression doDynamicCompression="true" /> in the web.config, which is a bit strange since I don't care for compressing URLs.

Whatever. I do now have Content-Encoding: gzip in the response headers for my site - so I assume its working.

Upvotes: 2

Carlos Aguilar Mares
Carlos Aguilar Mares

Reputation: 13581

Could you enable Failed Request Tracing, it should include information about what could be happening, it usually falls into a few buckets, 1) Permissions to generate the compressed file, 2) File is too small to require compression, 3) File is not being frequently enough so it is not being compressed, 4) mimetype issue

http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis7/

Upvotes: 1

Related Questions