1

In my application I'm using absolute expiration for a cache entry:

HttpContext.Cache
.Insert (cacheKey, true, null, DateTime.UtcNow.AddMinutes (3), TimeSpan.Zero,
         CacheItemPriority.Default, SomeCallbackFunction);

Everything is working more or less fine except that the expiration does not always happen precisely after 3 minutes but often about 20 seconds too late. I've been wondering, is any kind of precision guaranteed for cache entries? Is it something that can be configured in IIS or elsewhere? Anything else that can influence the precision?

I'm running 2008 R2 with IIS 7.5 (not the development server).

UPDATE: Linking to another question where a good answer has been given: Changing frequency of ASP.NET cache item expiration?

Community
  • 1
  • 1

1 Answers1

1

Look at this related question.

Clearing expired items runs on a timer with a frequency of 20 seconds under some conditions, which probably explains what you're observing.

Community
  • 1
  • 1
Joe
  • 122,218
  • 32
  • 205
  • 338
  • Thank you for the tip. It is very likely to be the reason. I've corrected my question, the issue I'm observing is exactly when I'm using a callback function, so I say the conditions do match those described in the linked question. –  Jun 03 '11 at 15:00