I’m currently developing a site in ASP.NET Webforms..
I’m caching things where it makes sence… adding things using High / Normal / Low priority..
telling them to stay in the cache for 2 weeks, 1 week, 4 hours respectably
im showing the current number of cached items on every page (for debug reasons).
sometimes if i travel through the site quickly the number of items in the cache can get upto 2000 items… but if i wait 5 mins and refresh the page the cache goes down to 20 items.. (just what was cached on that page)
is there any way i can find our what’s going on? and is there a reason for this that im missing?
im running Win7, 4Gb ram, 64 bit, VS10, .net4,
i have 4 gigs of ram so why should my cache completely empty?
i would say 10% of the cached items are about 4k each the rest would be strings about 100 chars long.
EDIT: I’m using Sliding Expiration
EDIT: I sorted it out, there were one or two items that were VERY BIG and they were set to High Priority.. that and some other smaller changes fixed my problem.
It won’t matter how long you tell it to stay in the cache if the app pool is set to recycle every xx minutes. On most Servers the app pool recycles by default every 1440 minutes (24 hours). Your cache can’t survive that app pool recycle unless you persist the data.
I don’t persist that long (almost never really practical). I also set the app that if the cache has been purged to rebuild itself AS IT NEEDS THE DATA – not all at once.
You could also be using more RAM than the app pool is configured to allow, too much CPU, etc.
And if this is running on a developer machine everytime you reset the app or reload Visual Studio everything is also erased as well.
Look at your App Pools and you will probably see the culprit for the resets.