Освежая в Restsharp для Windows Phone
-
15-11-2019 - |
Вопрос
Успешно реализовал Restsharp в моем приложении WP7, но остается одна проблема:
Когда я загружаю ресурсы с сервера (например, запрос на получение на http:// localhost: 8080 / автомобили ), первый раз, когда коллекция (в данном случае) автомобили успешно возвращаются.
Решение
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();