简体   繁体   English

如何在Mono MVC2应用程序中清除OutputCache

[英]How to clear OutputCache in Mono MVC2 application

AddCacheItemDependency is used to clear OutputCache in Mono Apache MVC2 application using code below. AddCacheItemDependency用于使用下面的代码在Mono Apache MVC2应用程序中清除OutputCache。 This is described in Clearing Page Cache in ASP.NET 在ASP.NET清除页面缓存中对此进行了描述

In Mono, OutputCache is not cleared. 在Mono中,不清除OutputCache。 Looking into source code in GitHub shows that AddCacheItemDependency is not implemented in Mono. 查看GitHub中的源代码可知,在Mono中未实现AddCacheItemDependency。 How to fix this so that OutputCache can cleared ? 如何解决此问题,以便可以清除OutputCache?

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: 在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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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