Skip to content

Instantly share code, notes, and snippets.

@realtebo
Forked from cristoni/service-worker.js
Created November 15, 2018 08:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realtebo/48ba29ae6987ad793ad9a852e06f719a to your computer and use it in GitHub Desktop.
Save realtebo/48ba29ae6987ad793ad9a852e06f719a 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