gpt4 book ai didi

iphone - Monotouch - iphone HttpWebRequest 关闭缓存?

转载 作者:行者123 更新时间:2023-12-03 21:20:54 26 4
gpt4 key购买 nike

我正在使用 monotouch 创建一个 iphone 应用程序,该应用程序调用一个返回 JSON 的不确定页面。

这很奇怪......但是当我使用 HttpWebRequest 时,我收到的输出是从较早的请求中缓存的。

我使用秒表计时,我必须等待两分钟才能获得页面的新版本,直到此时每次我调用 HttpWebRequest 时我都会得到已缓存的输出。

即使我终止应用程序并重新加载它,两分钟窗口的输出仍然相同。

这会发生在模拟器和手机上。

我刚刚尝试添加缓存策略,但没有高兴 - 我仍然将所有响应缓存 2 分钟。

这是我最新的代码:

Uri address = new Uri(url);
HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest;

System.Net.Cache.RequestCachePolicy c = new System.Net.Cache.RequestCachePolicy();
c.Level = RequestCacheLevel.NoCacheNoStore;
request.CachePolicy = c;
request.Timeout = Settings.RequestTimeout;
HttpWebResponse response = request.GetResponse();

有人有什么想法吗?

最佳答案

仅供引用,但 Mono 的 HttpWebRequest 实现尚未执行任何缓存。将来可能会实现,但从 2.10.3 开始还没有实现。

关于iphone - Monotouch - iphone HttpWebRequest 关闭缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4983782/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com