刷新在Windows手机的RESTSHARP中
-
15-11-2019 - |
题
我在我的wp7应用程序中成功实现了realsharp,但仍然存在一个问题:
当我从服务器加载资源时(例如,在 http:// localhost:8080 / cars ),第一次收集(在这种情况下)汽车成功返回。
当我第二次发出相同的请求时,我总是同样的结果是第一次 - 即使资源在该使用情况下改变。在查看我的服务器时,第二次没有请求发出。
解决方案
You can control caching of resources by setting headers on the response your server sends back. If you do not want the resource to be cached then set the cache-control header to no-cache.
It is the server's job to specify how long a resource is good for, the client should do its best to respect that information.
If you really, really want to delete entries in the cache you need to go via the WinINet API
其他提示
As a quick hack to avoid caching you can append a unique value to the end of the query string. The current DateTime (including seconds and milliseconds if necessary) or a GUID are suitable.
eg.
var uri = "http://example.com/myrequest?rand=" + DateTime.Now().ToString();