【问题标题】:How to Clear OutputCache for Website without Restarting App如何在不重新启动应用程序的情况下清除网站的 OutputCache
【发布时间】:2008-08-31 21:03:14
【问题描述】:

有没有办法在不重启的情况下清除或重置整个网站的输出缓存?

我刚开始在网站上使用 outputcache,当我设置错误时,我需要一个可以浏览的页面来重置它。

【问题讨论】:

    标签: asp.net outputcache


    【解决方案1】:

    这应该可以解决问题:

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    
     Dim path As String
     path="/AbosoluteVirtualPath/OutputCached.aspx"
     HttpResponse.RemoveOutputCacheItem(path)
    
    End Sub
    

    【讨论】:

    • 这个答案实际上并没有清除原始问题中指定的“整个网站”的缓存。
    【解决方案2】:

    将以下代码添加到控制器或页面代码:

    HttpContext.Cache.Insert("Page", 1);
    Response.AddCacheItemDependency("Page");
    

    要清除输出缓存,请在控制器中使用以下命令:

        HttpContext.Cache.Remove("Page");
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-15
      • 1970-01-01
      • 1970-01-01
      • 2021-10-06
      • 2017-08-13
      相关资源
      最近更新 更多