Prevent Silverlight xap from being cached by proxy server

非 Y 不嫁゛ 提交于 2019-12-01 17:02:29

问题


The company I work for has proxies/WAN accelerators between our international sites to cache Intranet web content. I have a Silverlight application being hosted on a server at one location, but being accessed by clients in another location. When the users access the web page hosting the Silverlight app, they get the stale xap file being cached by the proxy and not the latest version from the server. Local users always get the latest xap as their requests are not going through a proxy.

I've tried the various header/metadata techniques mentioned elsewhere to prevent caching, and the containing web page itself is being served up fresh, but I still get the old .xap file. Short of getting our IT admin to disable proxy caching for my site, is there anything I can do make sure the latest xap file get retrieved from the server instead of the proxy? The containing page is ASP.NET.


回答1:


What I do is just add a querystring at the end of the path to the xap file. Then when you change the querystring variable, the proxies etc. should see it as a request to a new file. So far this has worked fine for me.

So basically, when embedding an .xap in a straight-up HTML file, you would do this:

<param name="source" value="ClientBin/SilverlightApplication1.xap?cachepreventer=whatevervalue"/>

And then when you deploy a new version, just change "whatevervalue" to something else.

EDIT
If you need to use this technique in many places in your app I would read the querystring value from config and just write it to the page using asp.net. That way you only need to update it in one place when you deploy.




回答2:


If you want to make sure every time the xap file is retrieved and you don't want to worry about it - just use <param name="source" value="ClientBin/YourSilverlightapp.xap?<%=Guid.NewGuid().ToString() %>"/>

of course - this lends itself to a heavier cache load. I do like the helper method above though if you only want changes to be propagated to the client.



来源:https://stackoverflow.com/questions/2157259/prevent-silverlight-xap-from-being-cached-by-proxy-server

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