Skip to content

Instantly share code, notes, and snippets.

@webmaxru
Created February 27, 2019 22:43
Show Gist options
  • Save webmaxru/fd6fc919bdc809310235198aa3778ee5 to your computer and use it in GitHub Desktop.
Save webmaxru/fd6fc919bdc809310235198aa3778ee5 to your computer and use it in GitHub Desktop.
Workbox 4: workbox-window. Service worker
// For the simplicity let's use Workbox hosted on CDN
importScripts('https://storage.googleapis.com/workbox-cdn/releases/4.0.0/workbox-sw.js')
// Detailed logging is very useful during development
workbox.setConfig({debug: true})
// Updating SW lifecycle to update the app after user triggered refresh
workbox.core.skipWaiting()
workbox.core.clientsClaim()
// We inject manifest here using "workbox-build" in workbox-build-inject.js
workbox.precaching.precacheAndRoute([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment