防止 Silverlight xap 被代理服务器缓存
我工作的公司在我们的国际站点之间设有代理/WAN 加速器,用于缓存 Intranet Web 内容。我有一个 Silverlight 应用程序托管在一个位置的服务器上,但由另一个位置的客户端访问。当用户访问托管 Silverlight 应用程序的网页时,他们会获取代理缓存的陈旧 xap 文件,而不是来自服务器的最新版本。本地用户始终可以获得最新的 xap,因为他们的请求不通过代理。
我已经尝试了其他地方提到的各种标头/元数据技术来防止缓存,并且包含的网页本身正在重新提供,但我仍然得到旧的 .xap 文件。除了让我们的 IT 管理员禁用我的网站的代理缓存之外,我能做些什么来确保从服务器而不是代理检索最新的 xap 文件吗?包含页面是 ASP.NET。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我所做的只是在 xap 文件路径的末尾添加一个查询字符串。然后,当您更改查询字符串变量时,代理等应该将其视为对新文件的请求。到目前为止,这对我来说效果很好。
所以基本上,当将 .xap 嵌入到直接的 HTML 文件中时,您可以这样做:
然后当您部署新版本时,只需将“whatevervalue”更改为其他值即可。
编辑
如果您需要在应用程序的许多地方使用此技术,我将从配置中读取查询字符串值,然后使用 asp.net 将其写入页面。这样,您在部署时只需在一处更新它。
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:
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.
如果您想确保每次检索 xap 文件并且您不想担心它 - 只需使用
当然 - 这会导致更重的缓存负载。如果您只想将更改传播到客户端,我确实喜欢上面的帮助程序方法。
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.