1

Is it possible to find all Action methods on all controllers that have been decorated with [OutputCache] so I can then enumerate through them to remove selected items from the cache in one go?

foreach(var .. in ...)
{
  //get ActionName
  //get ControllerName
  HttpResponse.RemoveOutputCacheItem(Url.Action(ActionName, ControllerName));
}

According to this post it is not possible to invalidate the cache in one go.

Edit It looks like I can invalidate the ALL the cache by simply doing this:-

public ActionResult Invalidate()
{
    OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
    return View();
}

See this post for more info. However it would be nice to invalidate portions of the cache depending say on controller name etc.

Community
  • 1
  • 1
Rippo
  • 22,117
  • 14
  • 78
  • 117

1 Answers1

1

Looks like

public ActionResult Invalidate()
{
    OutputCacheAttribute.ChildActionCache = new MemoryCache("NewDefault");
    return View();
}

has done the trick...

Rippo
  • 22,117
  • 14
  • 78
  • 117