Adding a manifest to an existing site

Can I add a cache manifest right after the page loads? How to add attribute to html tag with JavaScript and reload / reload page?

I want to add a cache page manifest to the page, but I cannot edit the HTML itself.

+6
source share
2 answers

Some tests that I did some time ago found that it only works if you are redirected to a site where the cache manifest is explicitly specified.

Application cache works for each domain. This gives us two different cases: 1. this is a site in our domain or 2. this is an external site.

  • Since you only need to specify a manifest on the main site (or on any other site that is guaranteed to be visited, otherwise you may get strange behavior), you can simply put a bouncer in front of your house: Make a dummy page (= bouncer showing a counter or progress bar ), which explicitly indicates the cache pointer. This dummy page can also check if there are any changes and change the cache. After downloading all the resources, you are simply redirected to the "real" entry point of your application (access using a bouncer).

  • If this is an external page, you need to choose another workaround, for example, read the contents of the site on the server side and fix it there (so that it looks like the site of your domain). You can also cache an external site, like any other resource, and load the external site in an iframe, but just enter: the URI displayed in the browser should be in your domain. If you think about it, this is just reasonable, otherwise I could create a site that caches stackoverflow forever, and everyone who visited my site would not have more updates from stackoverflow (simplified, but it should get the exact point).

+1
source

The cache manifest describes the files needed to run your application "offline". You may not set the manifest attribute after loading the page. The HTML file has already been sent, and the browser will not respond to the dynamically added attribute of the manifest.

You can try "scraping the page" on the server side and transfer / paste the content to a new HTML page with a manifest (proxy style).

+1
source

Source: https://habr.com/ru/post/985937/


All Articles