IIS 7 and Above
IIS7 Output Caching - only lives in cache for 60 seconds?
Last post Jan 14, 2012 05:32 PM by steve schofield
Jan 12, 2012 08:38 PM|_bleach|LINK
I'm trying to cache the JSON output of an HTTP Handler (NOT an ASP.NET page, so the Page-level OutputCache directive does not apply). I'm running IIS 7.5 on Windows Server 2008.
I've added lines to the Web.config to enable caching in user mode (not kernel mode, as I need authentication):
<caching enabled="true" enableKernelCache="false">
<!-- cache content according to full query string for 12 hours -->
<add varyByQueryString="*" duration="12:00:00" policy="CacheForTimePeriod" extension=".aspx" />
<urlCompression dynamicCompressionBeforeCache="true" />
<!-- cache content that's requested twice in 30 minutes -->
<serverRuntime enabled="true" frequentHitThreshold="2" frequentHitTimePeriod="00:30:00" />
The content does successfully
cache, but it lives only for 60 seconds. I have looked all
over the various config files (Web.config, applicationHost.config, machine config) for a some sort of TTL of 60 seconds, but I'm at a loss.
I suspected that the cache scavenger might be eating my cache entries each time it runs. I modified the registry key so the scavenger runs less often; that did not help.
I also suspected that IIS was overagressively clearing out the cache because the machine is using a lot of its physical RAM. This particular server has about 66% physical RAM saturation. I attempted to allocate a static amount (1 GB) to the output
cache, rather than allowing IIS to manage the cache, but that was also unsuccesful.
Thanks in advance.
EDIT: I was finally able to solve this problem by modifying the OutputCacheTTL and ObjectCacheTTL registry values, as described in this
very helpful article. Seems the Microsoft documentation is rather incomplete.
Jan 14, 2012 05:32 PM|steve schofield|LINK
Windows Server MVP - IIS
Log archival solution
Install, Configure, Forget