Does Silverlight cache web service calls?

后端 未结 4 1340
感动是毒
感动是毒 2021-01-24 18:01

Here\'s the problemo:

My Silverlight application is calling a HTTP web service, using WebClient, called getCampaigns which returns a JSON array of data for Campaign obje

相关标签:
4条回答
  • 2021-01-24 18:41

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

    0 讨论(0)
  • 2021-01-24 18:56

    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.

    0 讨论(0)
  • 2021-01-24 18:57

    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

    0 讨论(0)
  • 2021-01-24 19:03

    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.

    0 讨论(0)
提交回复
热议问题