Does Silverlight cache web service calls?

别来无恙 提交于 2019-12-02 03:04:05

Any HTTP GET requests in Silverlight tend to cached, so if you want to eliminate caching by the client browser use HTTP POST to make web service calls. For example in WCF RIA Domain Services mark your invoke and query methods as such:

[Invoke(HasSideEffects = true)]
[Query(HasSideEffects = true)]

HasSideEffects simply states that it should use the POST method to avoid the caching mechanism of the client GET. Remember SL by default uses the browser to make web service calls and by default uses GET which is cacheable. That's why your web service calls to services even outside of RIA are being cached: the browser's seeing you use HTTP GETs and is caching the result.

The use of GET by default for web service calls is for performance reasons because POST responses are uncacheable by all major browsers per RFC 2616 which states that POST should be an idempotent operation (aka always results in an expected result which caching would break because the result may change over time).

Other operations in RIA involve setting caching by using LoadBehavior on LoadOperations.

There is no cache of web service calls. You probably have a problem in your refresh method.

https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=340931&wa=wsignin1.0

Two workarounds are given. I'm appending a Guid to my Url, so each web service call is completed using a unique Url.

This is an old thread but I'll chime in just in case someone comes across the same problem. A work around is if you have access to the user's browser is to set do refresh the cache for every page request. You do this by going into IE's Internet Options (IE 8), then in the General Tab go the Browsing History Settings button and select "Every time I visit the webpage" Hope it helps someone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!