开发者

How can you prevent Silverlight Client Http request from caching respones?

I am using a HttpWebRequest created from WebRequestCreator.ClientHttp.Create() to fetch data from a webservice. And everything seemed to be working fine until I found out the calls where being cached. I was pretty sure that the ClientHttp did not include caching, but after a bit of searching I found this little note:

Client HTTP Processing

  • Caching support

http://msdn.microsoft.com/en-us/library/dd772166(VS.95).aspx#networking

Which is the what's New in Silverlight 4 page on MSDN. But that is almost the only information I can find. I found another post claiming that the ClientHttp will request respect no-cache headers from the server, but I really would prefer that my Silverlight application was not dependent on a开发者_JS百科 server-side setting.

The usual fix to this problem is to simply add a random parameter to each call, but I really would like a more elegant solution.

Is there a way to simple disable the cache on ClientHttpWebRequest? - Preferable on single call and not a global setting.


The documentation you link seems to say that caching is not enabled in ClientHttp. However I'm also seeing behavior that looks suspiciously like GET response caching. I don't see a way to disable it either.


I don't think there's a way to control this from the client side. On the server side, setting Cache-Control = no-cache caused errors for me, but I was able to prevent the client stack from caching content by setting the Expires header to a date in the past (Response.Expires = -10;).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜