2
AddCacheItemDependency用於使用下面的代碼清除Mono Apache MVC2應用程序中的OutputCache。 這在Clearing Page Cache in ASP.NET如何在Mono MVC2應用程序中清除OutputCache
中描述在單聲道,OutputCache不清除。 在GitHub中查看源代碼顯示AddCacheItemDependency未在Mono中實現。 如何解決這個問題,使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);
}
在Global.asax.cs中:
protected void Application_Start()
{
HttpRuntime.Cache.Insert("Pages", DateTime.Now);
}
這reqires知道確切的網址。 Url也可以包含查詢字符串參數wchic可以改變。如何獲得緩存中的所有網址? – Andrus