Is it possible to add a cache manifest programmatically right after the page was loaded? Like adding the attribute to the html
tag with JavaScript and re-init/re-load the page?
I want to add a cache manifest to a page but cannot edit its HTML itself.
Some tests I did a while ago found that it was only working if you redirect to a site where the cache manifest is correctly specified.
The application cache works per domain. This gives us two different cases: 1. it's a site on our domain or 2. it' an external site.
Because you only need to specify the manifest on the main site (or any other site that is guaranteed to be visited, otherwise you can get strange behaviour) you can just put a bouncer in front of your house: Make a dummy page (=bouncer, displaying a spinner or progress bar) whith the cache manifest correctly specified. This dummy page can also check if there were changes and swap the cache. After loading all resources you just redirect to the "real" entry point of your application (the bouncer granted access).
If it is an external page, then you have to choose another workaround like reading the content of the site on the server side and correct it there (so that it looks like it's a site on your domain). You can also cache the external site like any other resource and load the external site in an iframe, but simply put: the URI displayed in the browser has to be on your domain. If you think about it, it's just reasonable, otherwise I could make a site that caches stackoverflow forever and everyone who visited my site will have no more updates from stackoverflow (oversimplified, but it should get the point accross).