0

I have a ASP.NET MVC 4 application which is running on a Windows 2012 R2 with IIS 8.5 machine. There is a wierd behavior which I cannot figure it out. The cache seems is clearing itself. By cache, I mean MemoryCache.Default, HttpContext.Current.Cache, and also OutputCache. I'm googling the issue for hours and seems nothing is wrong. Can you list cause of clearing cache? I mean is there a checklist which I can test the server against it? Thanks in advance.

5
  • did you delete a file under your IIS folder? Deleting a file under IIS folder causes the IIS to restart Commented Jan 25, 2015 at 13:38
  • When does the cache clear itself? Always after the same amount of time? Commented Jan 25, 2015 at 13:44
  • @KhanhTO, Messing with the application folder would only cause the application to restart, not for a full IIS restart. Commented Jan 25, 2015 at 15:03
  • @Javad_Amiry, You need a configure a distributed cache Commented Jan 25, 2015 at 15:04
  • @haim770: That's what I meant, sorry about using the wrong word. Commented Jan 25, 2015 at 15:04

1 Answer 1

1

Those caches are held in memory, and as such are volatile. They are held against the W3wp process that IIS spawns to handle those requests.

After a period of inactivity, IIS closes down the processes, so these caches will be cleared.

IIS also closes down the processes (recycles the app pool)

  • By default after 1746 mins (IIRC)
  • After the memory used by a thread reaches a set threshold
  • Caches are also isolated by thread, so if you have a web farm/web garden, these caches are not shared, again IIRC

If you need to persist these items longer, then you will need to look at caching the objects in a persisted storage area, such as a db or application state managed server.

Sign up to request clarification or add additional context in comments.

1 Comment

I do have a web garden :) Thanks a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.