IIS7 Output Caching - only lives in cache for 60 seconds?

2.3k Views Asked by At

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):

<system.webServer>      
    <caching enabled="true" enableKernelCache="false">  
        <profiles>
            <!-- cache content according to full query string for 12 hours -->
            <add varyByQueryString="*" duration="12:00:00" policy="CacheForTimePeriod" extension=".aspx" />
        </profiles>             
    </caching>      
    <urlCompression dynamicCompressionBeforeCache="true" />
</system.webServer>

<location path="Content">
    <system.webServer>
        <!-- cache content that's requested twice in 30 minutes -->
        <serverRuntime enabled="true" frequentHitThreshold="2" frequentHitTimePeriod="00:30:00" />               
    </system.webServer>
</location>  

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.

I believe this is the same question as asked on this Stack Overflow page but that guy never got an answer.

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 incompletel.

0

There are 0 best solutions below