Skip to content

Instantly share code, notes, and snippets.

@cristoni
Created November 15, 2018 07:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cristoni/daf391f9a3354e7579c373d762ef5cd4 to your computer and use it in GitHub Desktop.
Save cristoni/daf391f9a3354e7579c373d762ef5cd4 to your computer and use it in GitHub Desktop.
Esempio di service worker con workbox per workbox-webpack-plugin
if (workbox) {
console.log(`Yay! Workbox is loaded 🎉`);
// workbox.setConfig({ debug: false });
// workbox.precaching.suppressWarnings();
workbox.precaching.precacheAndRoute(self.__precacheManifest, {});
workbox.routing.registerRoute(/^https?.*/, workbox.strategies.networkFirst(), 'GET');
} else {
console.log(`Boo! Workbox didn't load 😬`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment