Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Created June 22, 2017 16:49
Show Gist options
  • Save daliborgogic/76a6cec2d9db0f19a775183596fdd18e to your computer and use it in GitHub Desktop.
Save daliborgogic/76a6cec2d9db0f19a775183596fdd18e to your computer and use it in GitHub Desktop.
Service worker dev
// This service worker file is effectively a 'no-op' that will reset any
// previous service worker registered for the same host:port combination.
// In the production build, this file is replaced with an actual service worker
// file that will precache your site's local assets.
// See https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
self.addEventListener('install', () => self.skipWaiting())
self.addEventListener('activate', () => {
self.clients.matchAll({ type: 'window' }).then(windowClients => {
for (let windowClient of windowClients) {
// Force open pages to refresh, so that they have a chance to load the
// fresh navigation response from the local dev server.
windowClient.navigate(windowClient.url)
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment