Thursday, December 17, 2009 by Administrator
I noticed recently that IIS7 wasn't compressing my static files
even though IIS looked as if it was configured correctly.
After an hour of googling and tinkering I had found a great
feature in IIS which allows you to view the cycle of a request to
which helped diagnose the problem.
First of all I had to install and enable failed request
tracing.
Once you have enabled failed request tracing select your site
node and then in the features view, click 'failed request
tracing rules'. Click add, next, enter 200, next, click finish.
Now, request a file which you expect to be
compressed...this should generate some log files.
By default you should be able to find them in
c:\inetpub\logs\FailedReqLogFiles\w3svcx. Open some of the files in
IE and find one which is a request for a static file. Next, click
the 'request details' tab and have a look at the request cycle.
Search for STATIC_COMPRESSION_START
On my server I then found the following trace:
STATIC_COMPRESSION_NOT_SUCCESS
Reason 14
Reason NOT_FREQUENTLY_HIT
The NOT_FREQUENTLY_HIT reason seemed like that could be the
issue as the website in question isnt busy at all. As is turns out
it looks as if IIS doesn't bother compressing files which aren't
frequently hit...which I dont really see the point of (but I'm sure
there must be one!) as long as the server has enough spare CPU why
not send back a compressed response?
Anyway, I ended up finding the config element below:
<serverRuntime frequentHitThreshold="1"
/>
Which I set in:
C:\Windows\System32\inetsrv\config\applicationHost.config
Setting frequentHitThreshold="1" seemed to do the trick...all my
js/css files etc are now compressed. Happy days.