Skip to content

Commit

Permalink
chore: remove service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
egoist committed Mar 22, 2019
1 parent 7c41dbd commit 7db5b1e
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions website/docs/sw.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
importScripts(
'https://storage.googleapis.com/workbox-cdn/releases/3.6.1/workbox-sw.js'
)

self.addEventListener('install', e => {
self.skipWaiting()
})

const ALLOWED_HOSTS = [
// The domain to load markdown files
location.host,
// The domain to load external scripts like Prism components
'unpkg.com'
]

const matchCb = ({ url, event }) => {
return event.request.method === 'GET' && ALLOWED_HOSTS.includes(url.host)
}

workbox.routing.registerRoute(matchCb, workbox.strategies.networkFirst())
self.addEventListener('activate', e => {
self.registration
.unregister()
.then(() => {
return self.clients.matchAll()
})
.then(clients => {
clients.forEach(client => client.navigate(client.url))
})
})

0 comments on commit 7db5b1e

Please sign in to comment.