2012-10-16 23 views
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); 
} 

回答

0

你嘗試手動刪除輸出緩存?

像:

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

這reqires知道確切的網址。 Url也可以包含查詢字符串參數wchic可以改變。如何獲得緩存中的所有網址? – Andrus

相關問題