views:

773

answers:

7

I'm assuming the issue I'm having is related to caching. Code changes I make are not getting picked up when I debug. Most times I get served a previous version of the app. How do I prevent this from happening?

A: 

As far as I see, this seems to be a problem with Firefox - when I used IE8, this didn't happen to me (I realize this may open its own can of worms, but at least for debugging and testing Silverlight, IE is much better)

Paul Betts
A: 

I have not had any issues with Silverlight assemblies getting cached - you might want to try debugging the HTTP requests that go back and forth, to see if maybe your server is instead returning incorrect information to the browser (e.g. a "not modified" response).

For general no-cache behavior, the only reliable method I have found is to turn off caching in the browser.

For IE, this has been the only reliable option - otherwise, even if proper no-cache headers are sent, certain things are still cached (specifically, dynamically loaded resources which are accessed via Javascript XmlHttpRequest). I have not specifically had issues with Silverlight getting cached when it should not, though - IE has always loaded the latest updates even if cache is enabled.

Firefox has been much more problematic - even when disabling cache, it still sometimes caches XmlHttpRequest-loaded resources. Manually hitting Refresh a few times has been the only solution in such a case. Once again, I have had no issues with Silverlight assembles, even if cache is turned on.

Sander
A: 

In Firefox, I use the 'web developer' plugin and simply select to 'disable cache'. Works fine.

DaRKoN_
+2  A: 

Try to add on the page what hosted SilverLigth appl on Page_Load:

      Response.Cache.SetExpires(DateTime.Now.AddSeconds(-100));
      Response.Cache.SetCacheability(HttpCacheability.NoCache);
cromacl
+1  A: 

Ctrl+F5 is an easy way to refresh a page and clear the cache of that page at the same time - it may help :)

Chris
A: 

Firefox 3.5 under Tools has the option for Private Browsing. Click that to disable caching.

steveolyo
A: 

Append a "version" querystring to your XAP Url, something like:

http://localhost:1234/ClientBin/my_silverlight_app.xap?v=1.0.287.5361

This will trick the browser (and many web servers) to think that this is a different file. And when the cache problem appears again, increase the number.

If you then want to employ proper caching, do it on the server-side with OutputCache directives.

chakrit