IIS gzip compression: the missing link

I’ve been wanting to enable gzip compression for our static content (javascript and css files) for a while but just haven’t been able to get IIS 7 to comply. Apparently static compression is enabled by default in IIS 7 but when inspecting traffic using fiddler I wasn’t seeing my static content compressed.

Solution at last

After several hours of googling and trying various unsuccessful solutions I finally found the answer! Buried in the comments of a post on Rick Strahl’s blog, Imad Jureidini had pointed out the following:

I’ve been running into the same issues. Ultimately, the solution was to change the following config setting:

<serverruntime frequenthitthreshold=”1″>

The default value here is “2”, which means that even static content does not get compressed if it isn’t requested twice within a 10 seconds period (frequentHitTimePeriod). Switching to “1” means that the file gets compressed right away.

Hopefully this will fix your problems too 🙂

– Imad

To confirm that this was in fact the problem I was experiencing I did a control refresh of my website several times in very quick succession. Sure enough the css and javascript files suddenly started coming through compressed.

I then used the following command to change the setting in my servers config:

%windir%system32inetsrvappcmd.exe set config
-section:system.webServer/serverRuntime -frequentHitThreshold:1

After restarting IIS I tried a control refresh of the website again. As expected the css and javascript files were delivered compressed on the first request.


This begs the question – why would Microsoft do such a thing? Surely the point of compression of static resources is to reduce delivery time to the browser. Why should my users care if anyone else has recently requested the particular resource they are interested in? They aren’t and shouldn’t be. These static resources should be compressed first, time everytime. (The only exception to this would be where compression is straining the servers ability to serve content).

Where is the documentation?

I’ve got to say my experiences with IIS 7 to date have been one frustration after the next. Microsoft appears to have put a lot of work into this product and at first glance a lot of the new features look to offer real value. What I don’t understand is why there is so little documentation on this new product. So much has changed from IIS 6 there really needs to be a comprehensive set of documentation available somewhere – if it does exist I have yet to find it…