In many actions from the MVC application we are building up, we use OutputCache as follows:
[OutputCache(Duration = 3600, VaryByCustom = "language")]
public ActionResult SomeAction()
{
//Action..
}
So, I want to have an action where I can flush manually all these caches:
public ActionResult RefrescarCache()
{
var keys = HttpContext.Cache.Cast<DictionaryEntry>().ToList();
keys.ForEach(k => HttpContext.Cache.Remove(k.Key.ToString()));
ViewBag.operationResult= "The cache was flushed succesfully!";
return View();
}
The thing, that it seems to not work. I will aprecciate any idea or advice you have!