I'm currently using the OutputCacheAttribute (in System.Web.Mvc) on an action:
[ChildActionOnly]
[OutputCache(Duration = 24 * 60 * 60)] // Cache for 24 hours
public ContentResult Render(string json, string pagePublished)
{
After the first page load it caches the output and holds it. It sometimes stays cached for hours, sometimes minutes.
I use this action on multiple pages, so first I thought it might have something to do with that. But I've tried to just cache one page and see if it holds, it does not. I've tried to cache a lot of pages and it sometimes holds for hours.
Anyone have an idea about what could be wrong?
EDIT:
The w3wp process uses huge amounts of RAM (this is by design and not a problem) there are still free RAM (about 5gb) for it to allocate. I have built another action that gets the current size of the httpcontext cache. This amounts to about 1350000 bytes. So there should not be a problem with memory.
I also have a problem with MemoryCache which also evicts items at random (Amounts to about 8530000 bytes.)
EDIT2:
It seems like it's saving the output from the action in both MemoryCache and httpcontext cache.