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.
-
did you delete a file under your IIS folder? Deleting a file under IIS folder causes the IIS to restartKhanh TO– Khanh TO2015-01-25 13:38:22 +00:00Commented Jan 25, 2015 at 13:38
-
When does the cache clear itself? Always after the same amount of time?Jan Köhler– Jan Köhler2015-01-25 13:44:37 +00:00Commented 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.haim770– haim7702015-01-25 15:03:24 +00:00Commented Jan 25, 2015 at 15:03
-
@Javad_Amiry, You need a configure a distributed cachehaim770– haim7702015-01-25 15:04:32 +00:00Commented Jan 25, 2015 at 15:04
-
@haim770: That's what I meant, sorry about using the wrong word.Khanh TO– Khanh TO2015-01-25 15:04:33 +00:00Commented Jan 25, 2015 at 15:04
Add a comment
|
1 Answer
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.
1 Comment
amiry jd
I do have a web garden :) Thanks a lot.