简体   繁体   中英

How to clear OutputCache in Mono MVC2 application

AddCacheItemDependency is used to clear OutputCache in Mono Apache MVC2 application using code below. This is described in Clearing Page Cache in ASP.NET

In Mono, OutputCache is not cleared. Looking into source code in GitHub shows that AddCacheItemDependency is not implemented in Mono. How to fix this so that OutputCache can cleared ?

Andrus.

[OutputCache(Duration = 3600, VaryByParam = "none")]
public ActionResult Index()
{
  HttpContext.Current.Response.AddCacheItemDependency("Pages");
  return View();
}

public ActionResult Refresh()
{
HttpRuntime.Cache.Insert( "Pages", DateTime.Now);
}

in Global.asax.cs:

protected void Application_Start()
{
HttpRuntime.Cache.Insert( "Pages", DateTime.Now);
}

Did you try remove output cache manually?

Like:

var urls = new List<string> {
                    Url.Action("Index", "ControllerName", new { area = "AreaName" }))
            };
urls.ForEach(HttpResponse.RemoveOutputCacheItem);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM