A service worker implementation of the behavior defined in a page's App Cache manifest.
npm install appcache-polyfill-swA pair of modules meant to ease the transition
off of AppCache
and on to
service workers.
Note: These libraries attempt to replicate the caching and serving behavior that AppCache offers, but does not include direct equivalents to the window.applicationCache interface, nor the related events that AppCache would fire in the window context.
There are two modules to install: one that is used from within the window
context in your web app, and the other that's used in the context of your
service worker.
``sh`
npm install --save-dev appcache-polyfill-window
npm install --save-dev appcache-polyfill-sw
As an alternative to local installation & serving, you can load both libraries from a NPM CDN, like https://unpkg.com/ or https://www.pika.dev/.
`html`
`js
importScripts('/path/to/appcache-polyfill-sw/build/index.umd.js');
self.addEventListener('fetch', (event) => {
// Alternatively, examine event.request and only use the
// appcachePolyfill.handle() logic for a subset of requests.
event.respondWith(appcachePolyfill.handle(event));
});
``
Please open an issue with feedback or bug reports if you run in to problems.