Skip to content

Instantly share code, notes, and snippets.

@fabriciofmsilva
Forked from davidgilbertson/sw-precache-config.js
Last active April 14, 2018 22:40
Show Gist options
  • Save fabriciofmsilva/c99f2f052d6a56a52a09fbf66ee144ff to your computer and use it in GitHub Desktop.
Save fabriciofmsilva/c99f2f052d6a56a52a09fbf66ee144ff to your computer and use it in GitHub Desktop.
swPrecache.write(path.resolve(__dirname, `../public/service-worker.js`), {
cacheId: `know-it-all`,
filename: `service-worker.js`,
stripPrefix: `public/`,
staticFileGlobs: [
`public/app.*.js`, // don't include the polyfills version
`public/*.{html,ico,json,png}`,
],
dontCacheBustUrlsMatching: [
/\.(js|json)$/, // I'm cache busting js and json files myself
],
skipWaiting: true,
}, (err) => {
if (err) {
reject(err);
} else {
resolve();
}
});
if (`serviceWorker` in navigator) {
navigator.serviceWorker.register(`service-worker.js`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment