3

I'm using a very simple outputcache directive on an ASP.NET 4.0 Webforms application (IIS 7.5), that caches pages for 1 hour. The application is not under any memory pressure, yet pages expire well before one hour. I created a test page that simply writes out DateTime.Now to confirm the behavior.

It does appear that as long as I continue to refresh the page it stays cached (mostly), but if I stop requesting it for a few minutes and return the datetime stamp changes. I've seen a few other people post similiar questions but no answers. I assume this has to do with some sort of configuration or optimization setting somewhere, where IIS that bumps seldom accessed pages from the cache earlier than the duration but I can't seem to find anything documented.

<%@ Page Language="C#" MasterPageFile="Default.Master" AutoEventWireup="true" Title="Test"%> <%@ OutputCache duration="3600" location="Any" varyByParam="*" %>

<%=DateTime.Now%>

rick schott
  • 21,012
  • 5
  • 52
  • 81
JNappi
  • 1,495
  • 1
  • 14
  • 24

2 Answers2

0

I was having a similar problem and increasing percentagePhysicalMemoryUsedLimit in Web.config seems to have fixed it. Previously at 25%, OutputCache was resetting every minute or so.

<system.web><caching>
    <cache privateBytesLimit="0" privateBytesPollTime="00:02:00"
           percentagePhysicalMemoryUsedLimit="50" />
Webveloper
  • 1,059
  • 10
  • 15
0

Do you have output cache set on the parent page or on any other controls on that page?

Also, how long is your app pool set to idle for before it shuts down? If your app pool recycles then your cache will be reset.

Caching Portions of an ASP.NET Page

You should also be aware of what happens when a user control with output caching set exists in a Web Forms page that also has output caching set. If the page output cache duration is longer than the user control output cache duration, the page output cache duration is effective for the entire page, including the user control. For example, if page output caching is set to 100 seconds and the user control output caching is set to 50 seconds, the entire page is stored in the output cache for 100 seconds, regardless of the shorter setting for the user control. The following example demonstrates this.

rick schott
  • 21,012
  • 5
  • 52
  • 81
  • The sample I gave is basically it, no nested controls, just a page, with a directive and a DateTime.Now. – JNappi Oct 06 '11 at 03:18