HTTP请求是否可能被无意中缓存?

时间:2014-04-29 21:41:57

标签: c# http caching networking

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

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

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

1 个答案:

答案 0 :(得分:0)

您可以尝试此(或其他RequestCacheLevel设置之一):

WebClient MyClient = new System.Net.WebClient() ;

MyClient.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);

string latestVersion = MyClient.DownloadString(
     "http://www.pixelchampions.com/latest.txt");