views:

882

answers:

2

How to do I prevent a Silverlight XAP file being cached by the web browser?

The reason I want to do this is during development I don't want to manually clear the browser cache, I'm looking for a programmatic approach server side.

Cheers

AWC

+2  A: 

Add a query parameter to the URL for the XAP in the element on the HTML Page:

  • clientBin/MyApp.xap?rev=1
  • clientBin/MyApp.xap?rev=2

It will be ignored and break the cache. In IE8, there are some cache management tools: Open the Developer tools:

  • Try Cache...Always Refresh from Server
  • Try Cache...Clear Browser Cache for this domain...
Michael S. Scherotter
Revision numbers on static resources can be quite effective when the URLs referencing them are generated dynamically so you can add these references. However it takes quite a bit of custom infrastructure to make this happen dynamically and without that the developer has to remember to upgrade the version number manually. It gets worse if the resource is used in multiple places. Since XAPs are not likely to be requested at high frequency from an individual client the occasional "unmodified" response is more desirable.
AnthonyWJones
+2  A: 

Using IIS management add a custom header Cache-Control with the value no-cache. That'll cause the browser to check that any cached version of the XAP is the latest before using it.

AnthonyWJones