views:

643

answers:

2

This question has been asked before but 1) the user never accepted an answer 2) none of them stand out as better than the others (votes-wise) and 3) the asker seems to have forgotten about it. So I'm going to ask it again so I can get to an accepted answer. And some of the users in the thread have said that some of the solutions didn't work. Sorry for cluttering up the place, but I promise to get to the bottom of this.

I ran into this problem the other day when I was looking at my Silverlight app in Firefox. I made a change to the location of an image and it didn't move. I assumed I did it wrong, but then I looked at IE7 and the image was in the right place. Turns out Firefox was displaying a cached version of the file; the changes I made didn't show up.

This is a larger problem: if I change my app (let's say it's an urgent typo correction) how can I force the end user to see the most current version of my Silverlight app? Is isolated storage (Heuer's blog) really the only way to force an update from the server side? Clearing the Firefox cache is not going to work for a push update; I need the update to propagate without the end user doing anything.

Update: Dino Esposito has some ideas about controlling this, specifically using the Expires property of the Response object. Haven't had a chance to try this yet.

+2  A: 

Can you encode the version number or timestamp in the filename? That way, if the page changes, Firefox will notice that it points to a completely different resource and will reload it.

Kevin
This answer is one of the answers on the other question and is probably the best solution. If you change the URL, the browser has no choice but to go download the new app.
Kibbee
So change the filename in code? Ugh, I hope that's not what I have to do...
jcollum
A: 

First, you need to build your application after every layout or code change. Silverlight is not html, it's code that runs locally.

Second, the actual solution to this:

  1. page.xaml loads, kicks off an async on the web service that sits on the underlying page
  2. webservice detects firefox
  3. if firefox, tell the response that it expires immediately

    [OperationContract] public bool DetectFirefox() { if ((HttpContext.Current.Request.Browser.Browser == "Firefox") && ((HttpContext.Current.Request.Browser.MajorVersion >= 2))) { HttpContext.Current.Response.Expires = -1; } return true; }

The only caveat here is that you'll need to add that code before you want it to kick in. Otherwise FF3 will be running the old version of your code that doesn't have the response expiration.

jcollum