i have this code:
[AcceptVerbs(HttpVerbs.Get)]
[OutputCache(Duration = 86400, VaryByParam = "*")]
public ActionResult GetData(MyParams myParams)
{
return GetDataEx(myParams);
}
to cache a bunch of Json on my web server.
i see on this page, it says
There is no guarantee that content will be cached for the amount of time that you specify. When memory resources become low, the cache starts evicting content automatically.
is there any way to get a specific callback when this item gets evicted from teh cache because of memory resources getting low. I don’t see the cache working properly but my guess is that i am running out of memory but if i had this callback, i could tell for sure.
With response output caching there is no way to be notified when the contents expires. And to be honest you shouldn’t really care about, if the contents is expired the controller action will simply be hit and the new contents cached again. Also notice that depending on the location where you configured this output cache to be stored, if it is downstream on intermediate proxy servers or client browsers, the cache expiration is totally out of your control.
If you are caching objects manually into the ASP.NET cache you could register a CacheItemRemovedCallback which will be executed when the item is removed but this doesn’t apply to response output caching which is what you are using here.