October 2017
Intermediate to advanced
370 pages
8h 57m
English
Now let's see how to install the service worker and the AMP page when it's served from the cache. We'll change our amp-install-serviceworker tag to look like this:
<amp-install-serviceworker src="https://theampbook.com/ch11/amp2pwa/sw.js" data-iframe-src="https://theampbook.com/ch11/amptopwa/sw-install.html" layout="nodisplay"></amp-install-serviceworker>
This time, note the data-iframe-src attribute. When AMP files are served from the cache, they're served from a different domain, so we need a way to install the service worker from a domain other than the one it will be used on. This can be achieved via an iframe. When a user visits the original domain, the src attribute is used to install the ...
Read now
Unlock full access