Basic Requirements
I have a SL app that can be run in-browser or out-of-browser. I want the browser to:
- Cache the xap file
- Load the xap from the cache if it has not changed or re-download it if it has changed.
More details
Setting a future expires header obviously solves the caching problem but then I cannot force the user to download the latest version. Normally I would just add a querystring to the url (eg url?v=1) but I cannot do this as this breaks the out-of-browser functionality. eg the app thinks it is not installed when in fact it is.
no cache
If I set Cache-Control to no-cache, Chrome and Firefox correctly send a request to the server for the xap but use the cache if a 304 is returned. IE8 just downloads the file again as does Safari.
must-revalidate
Setting Cache-Control to must-revalidate again works correctly in Chrome and Firefox but Safari always downloads the xap again while IE8 always uses the cache.
How do I set this up to work as described at the start of this question?
I’m not sure that the Chrome/Firefox is strictly “correct”, you have after all not told the browser that it should cache the content or even that the content is cacheable.
Instead of no-cache try “Cache-Control: max-age=15” instead. See if that convinces IE that it ought cache the content despite its large size (which is why its not caching it originally).
For OOB install use the
Applicationobject’sCheckAndDownloadUpdateAsyncmethod. Note you need to inform the user to restart the app once an update has been downloaded.