Windows Phone 용 RESTSHARP에서 새로 고침
-
15-11-2019 - |
문제
RESTSHARP를 WP7 응용 프로그램에서 성공적으로 구현했지만 한 가지 문제는 다음과 같습니다.
서버에서 자원을로드 할 때 (예 : http : // localhost : 8080 / cars ), (이 경우에) 자동차의 컬렉션이 성공적으로 반환되면서 처음으로 반환됩니다.
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();