【问题标题】:Disable browser caching for Google Chrome for a single ASP.NET web form为单个 ASP.NET Web 表单禁用 Google Chrome 的浏览器缓存
【发布时间】:2016-08-03 18:10:57
【问题描述】:

我在 page_load 事件中尝试了以下操作,但没有成功。 (注:页面语言为VB)

Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1))
Response.Cache.SetNoStore()
Response.Cache.SetMaxAge(New TimeSpan(0, 0, 30))

HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
HttpContext.Current.Response.Cache.SetValidUntilExpires(False)    
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)       
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
HttpContext.Current.Response.Cache.SetNoStore()

【问题讨论】:

    标签: asp.net vb.net caching


    【解决方案1】:

    我已经添加了一些代码来从浏览器中删除缓存。我添加了页面加载事件

                    List<string> keys = new List<string>();
                    IDictionaryEnumerator enumerator = Cache.GetEnumerator();
    
                    while (enumerator.MoveNext())
                        keys.Add(enumerator.Key.ToString());
    
                    for (int i = 0; i < keys.Count; i++)
                        Cache.Remove(keys[i]);
    

    在 vb.net 中

            Dim keys As List(Of String) = New List(Of String)
            Dim enumerator As IDictionaryEnumerator = Cache.GetEnumerator()
            While enumerator.MoveNext()
                keys.Add(enumerator.Key.ToString())
            End While
            For i = 0 To keys.Count - 1
                Cache.Remove(keys(i))
            Next i
    

    【讨论】:

      猜你喜欢
      • 2018-06-29
      • 2010-10-29
      • 2010-11-12
      • 2011-07-25
      • 1970-01-01
      • 1970-01-01
      • 2016-04-05
      • 1970-01-01
      • 2010-12-01
      相关资源
      最近更新 更多