title: IIS7 Output Caching - only lives in cache for 60 seconds?
body: <p>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.</p>
  
  <p>I've added lines to the Web.config to enable caching in user mode (not kernel mode, as I need authentication):</p>
  
  <pre><code>&lt;system.webServer&gt;      
      &lt;caching enabled="true" enableKernelCache="false"&gt;  
          &lt;profiles&gt;
              &lt;!-- cache content according to full query string for 12 hours --&gt;
              &lt;add varyByQueryString="*" duration="12:00:00" policy="CacheForTimePeriod" extension=".aspx" /&gt;
          &lt;/profiles&gt;             
      &lt;/caching&gt;      
      &lt;urlCompression dynamicCompressionBeforeCache="true" /&gt;
  &lt;/system.webServer&gt;
  
  &lt;location path="Content"&gt;
      &lt;system.webServer&gt;
          &lt;!-- cache content that's requested twice in 30 minutes --&gt;
          &lt;serverRuntime enabled="true" frequentHitThreshold="2" frequentHitTimePeriod="00:30:00" /&gt;               
      &lt;/system.webServer&gt;
  &lt;/location&gt;  
  </code></pre>
  
  <p>The content <em>does</em> successfully cache, but it <strong>lives only for 60 seconds</strong>. 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. </p>
  
  <p>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. </p>
  
  <p>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.</p>
  
  <p>I believe this is the same question as asked <a href="https://stackoverflow.com/questions/6067854/iis-7-output-caching-not-caching-long-enough" title="here">on this Stack Overflow page</a> but that guy never got an answer.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT:</strong> I was finally able to solve this problem by modifying the OutputCacheTTL and ObjectCacheTTL registry values, as described in <a href="http://www.ckode.dk/server-configuration/tuning-iis-7-for-static-content/" rel="nofollow noreferrer">this very helpful article</a>. Seems the Microsoft documentation is rather incompletel.</p>