在RestSharp中为Windows Phone刷新 [英] Refreshing in RestSharp for Windows Phone

查看:85
本文介绍了在RestSharp中为Windows Phone刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在WP7应用程序中成功实现了RestSharp,但是仍然存在一个问题:

I implemented RestSharp succesfully in my WP7 application, but one issue remains:

当我从服务器加载资源时(例如 http:// localhost:8080 / cars ),这是首次成功收集(在这种情况下)汽车的收藏。

When I load resources from the server (for example a GET request on http://localhost:8080/cars), the first time the collection of (in this case) cars is succesfully returned.

当我第二次发出相同的请求时,我总是获得与第一次相同的结果-即使资源已更改与此同时。当我查看服务器时,第二次根本没有发出请求。

When I issue the same request for the second time, I always get the same result as the first time - even when the resources have changed in the meantime. When looking at my server, the second time there is no request issued at all.

我认为RestSharp中实现了一种缓存机制,但是我看不出有什么方法可以使该缓存失效。缓存结果。

I presume there's a caching mechanism implemented in RestSharp, but I see no way to invalidate the cache results.

是否有任何方法可以手动使RestSharp for Windows Phone缓存结果无效? (或者强制库从服务器获取结果的方法)。

Are there any ways to manually invalidate the RestSharp for Windows Phone cache results? (Or ways to force the library to get the results from the server)

推荐答案

您可以通过将标头设置为on来控制资源的缓存您的服务器发回的响应。如果您不希望资源被缓存,则将cache-control标头设置为no-cache。
服务器的工作是指定资源的使用期限,客户端应尽力而为尊重这些信息。

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.

如果您确实要删除缓存中的条目,则需要通过 WinINet API

If you really, really want to delete entries in the cache you need to go via the WinINet API

这篇关于在RestSharp中为Windows Phone刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆