What makes XAP to download?

Every one knows when ever there is a new version of XAP file, Silverlight ActiveX control downloads the new version properly and all works. If you would Bing you will find out, people have trouble getting latest version of XAP file and there are lot of solution to it. So I am not going into that part. What I want to explain here is a scenario that we ran into, which is straight opposite. In our case XAP gets downloaded every time even when there is no changes the XAP file. It was a very interesting problem and I got great help from some of my colleagues to isolate and solve the problem. I thought I share it here for anyone looking for solution.

Let me explain the exact problem. In our QA environment when we open a brand new instance of IE, that is no other instance of IE is open and go to a Silverlight page for the first time, you can see that, XAP will be downloaded. Now navigate between the pages in the application and come back to the same page and you will notice, XAP will not be downloaded. So far is good. Now close all IE and launch IE again, go to Silverlight page, it will download XAP file again even though XAP file was downloaded a minute ago and we did not release any new XAP file either. Now, we though we could reproduce the problem in our development environment, but we couldn’t. In Development environment once you go the page, XAP get downloaded and close all IE and come back to the same page, it does not download XAP file again. It was a big puzzle.

I did some research on the internet and found out that, If I would set “HTTP Response header expiration’ for ClientBin folder in IIS to a specific time period, XAP will not download till the time period expires. Well it did not solve my real problem since I do not want to set the expiration time to too long. We knew there is still a problem that I am not finding. So I asked around and one of my colleague recommended me to check the HTTP header using Fiddler and he said it might give you an idea. He asked me to check for specifically


Here is link in wiki which really helped understand the cache. With that information and I knew what I am after, I ran the same test as explained before against our QA servers with Fiddler running. First attempt I got http response 200 for the XAP file as I expected.


Now with in the same application on the same instance of IE, move between pages and come back to the same page and I get 304 as expected and it will not download the file.


I closed all the IE instances and open Silverlight page again I did get 200 and only difference in this case was my ETag was different. I was curious why ETag is different, it turned out, in QA we have multiple servers which are running under load balancer so this time, load balancer send me to another server. Since the ETag value is different from the previous server and even though the last modified date and time is same, it ended up downloading the file. So the culprit in this case is ETag. Different QA servers have different ETag set. One of my friend send me a mail with issue with ETag and its solution recommended in Microsoft site. 

There is two solution, one recommended in the Microsoft web site to bring all your QA servers to same ETag base number. The other is just add the ETag to ClientBin foler as empty. In our case, we added ETag as empty and performed the test, now it no longer downloads the XAP file.

Hopefully it helps someone.


2 thoughts on “What makes XAP to download?

  1. “What makes XAP to download? Unni’s space” was in fact a terrific blog post, can not wait to look over a lot more of your postings. Time to squander numerous time on the web hehe. Thanks for your effort -Wayne

  2. Hello, thanks very much for the post. How did you “add the ETag to ClientBin foler as empty” ? I don’t see this option in the Microsoft link. Thanks!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s