Appending cache manifest to existing site
Asked Answered
S

2

6

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.

Saulsauls answered 25/4, 2015 at 10:11 Comment(1)
What do you think will happen to your modifications once you reload the page?Salpingectomy
S
1

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.

  1. 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).

  2. 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).

Sartin answered 25/4, 2015 at 10:34 Comment(0)
P
1

The cache-manifest describes the files needed to run your "application" "offline". You can not set the manifest attribute after the page was loaded. The HTML file is already sent and the browser will not react to a dynamically added manifest attribute.

You could try "scraping the page" on server side and wrap/embed the content into a new HTML page with manifest (proxy-style).

Pisolite answered 25/4, 2015 at 10:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.