Thread: ASP.NET/Tuning IIS7 for static content

Tuning IIS7 for static content

Tuning Instructions

Now the last piece missing in the puzzle: Where do you change these settings ? Well here goes:

frequentHitThreshold and frequentHitTimePeriod both reside in a file called "applicationHost.config", which is found in "%windir%\system32\inetsrv\config"

This file resembles web.config and machine.config quite a bit, so you should be familiar with the syntax.

The element these attributes are set on, is called "serverRuntime" and should exist already, albeit being empty.
e.g. it looks like this:

<serverRuntime />

The syntax for setting the attributes is as follows:

<serverRuntime frequentHitTimePeriod="00:00:10" frequentHitThreshold="1" />

so frequentHitTimePeriod is a TimeSpan, and frequentHitThreshold is an unsigned integer (should be 1 or more)

 Note that setting frequentHitTimePeriod is in fact superfluous when frequentHitThreshold is set to 1.

These changes take effect as soon as you save the file, and the result can be observed in perfmon immediately.

The last setting, ObjectCacheTTL resides in the registry database, and doesn't exist per default either. It's location is "HKEY_LOCAL_MACHINE\System\CurrentControlSet\services\InetInfo\Parameters"

Create a new DWORD (32-bit) value called "ObjectCacheTTL" and set its decimal value to the number of seconds, which should pass between the IIS flushing its cache for unused files. (It only removes files which weren't requested after initially being added to the cache)

There is however a minor quirk to this, as there is in fact *another* registry key, which does pretty much the same - only it doesn't... Confused ? That's understandable.

The thing is, IIS caches files either in user-mode or kernel-mode, and depending on which mode it caches in, it *may* use a different registry key for the flush interval.

 So to be certain it actually does what you want, create another DWORD (32-bit) value called "OutputCacheTTL" and give it the same value as ObjectCacheTTL.

If you have limited memory, your best bet is to modify only frequentHitTimePeriod as it has the least impact of the 3, and as such can be used for more subtle tuning, with little risk of consuming too much memory.