【问题标题】:Can HTTP requests be unintentionally cached?HTTP 请求会被无意缓存吗?
【发布时间】:2014-04-29 21:41:56
【问题描述】:

以下 HTTP 提取应返回字符串 262。对于我的一些用户(但不是全部,甚至大多数)来说,它似乎返回了一个较旧的值261

string latestVersion = new System.Net.WebClient().DownloadString(
    "http://www.pixelchampions.com/latest.txt");

我真的不知道为什么。 IIS7 主要使用默认设置。某些路由器/ISP 是否会缓存非查询 HTTP 请求的结果?

【问题讨论】:

    标签: c# http caching networking


    【解决方案1】:

    您可以试试这个(或其他 RequestCacheLevel 设置之一):

    WebClient MyClient = new System.Net.WebClient() ;
    
    MyClient.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
    
    string latestVersion = MyClient.DownloadString(
         "http://www.pixelchampions.com/latest.txt");
    

    【讨论】:

      猜你喜欢
      • 2018-08-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-08
      • 2014-11-25
      • 2012-04-05
      • 2016-06-29
      相关资源
      最近更新 更多