开发者

How do browsers handle caching of XAP packages?

As you k开发者_Go百科now all, you can build a silverlight XAP package and reference it using object tag on your HTML page or asp.net page.

When the browser downloads the XAP package from the server the first time the page is referenced by the user, if the user refreshes the same page, does it re-download the same XAP package or it uses the cached version?

If the user navigates to another page that uses the same XAP package and the XAP package was already downloaded because of the previous page the user was on, does the browser used a cached version or go to the server and downloads it again?

If the browser uses cached versions all the time, how does it know when to use cached version and when to use new version of XAP package since it may have been rebuild with new changes? Does it have something to do with the Version number of the package?


XAP is considered as a regular resource file same as image (png/gif/jpg etc). Browser does not download the new copy until its HTTP Cache conditions are matched which are out of scope to explain it here. The only solution we have adapted is to append "?tag" after the URL of XAP and tag can replace the version number which will force browser to re download the file.

So we tag our url like..

MySilverlightClient.xap?v1
MySilverlightClient.xap?v2

etc. So even if it is cached for current version there is no problem, but when a new version is changed on server side, we can change our tag v1 to something else that will force browser to consider it as a new URL and redownload it even if it is cached.


I can answer the first part of your question, which is that the browser uses a cached copy of the XAP when you revisit/refresh the page. In fact, it can be quite fun to get the browser to download a new copy!

Each browser behaves differently here, of course, with IE seeming to be the most stubborn about updating the XAP when the source file has changed. As Anthony points out in the comments, the XAP is being treated like any other content file according to the browser's default content file cache handling.

There are some good solutions in this similar question that cover other ways to ensure the XAP is updated:

Making the Silverlight XAP file expire from browser cache programmatically

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜