Windows Phone用のRestSharpの更新
-
15-11-2019 - |
質問
私は私のWP7アプリケーションでRestSharpを成功させましたが、1つの問題は残ります。
サーバからリソースをロードするとき( http:// localhost:8080 / cars )、(この場合)車の回収が初めて返されます。
2回目の間同じ要求を発行すると、i 常にリソースが変わってもリソースが変更された場合でも、常に同じ結果が得られます。私のサーバーを見るときは、2回目に要求はまったく発行されません。
RestSharpに実装されているキャッシングメカニズムがあると思いますが、キャッシュ結果を無効にする方法はありません。
Windows Phoneキャッシュの結果のRestSharpを手動で無効にする方法はありますか?(またはライブラリにサーバーから結果を得るための方法)
解決
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();