Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do browsers handle caching of XAP packages?

As you know 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?

like image 485
ActiveX Avatar asked Jun 14 '11 13:06

ActiveX


People also ask

How does browser caching work?

The basic idea behind it is the following: The browser requests some content from the web server. If the content is not in the browser cache then it is retrieved directly from the web server. If the content was previously cached, the browser bypasses the server and loads the content directly from its cache.

Are images cached in browser?

A browser or Web cache does exactly that, except with program and website assets. When you visit a website, your browser takes pieces of the page and stores them on your computer's hard drive. Some of the assets your browser will store are: Images - logos, pictures, backgrounds, etc.

Do browsers cache HTML pages?

Browser caching is a process that involves the temporary storage of resources in web browsers. A visitor's web browser downloads various website resources and stores them in the local drive. These include images, HTML files, and JavaScript files.

Does the browser automatically cache?

Almost every modern browser will cache . js, . css and images by default.


2 Answers

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.

like image 160
Akash Kava Avatar answered Oct 07 '22 00:10

Akash Kava


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

like image 35
Simon Steele Avatar answered Oct 07 '22 01:10

Simon Steele