Skip to content

Instantly share code, notes, and snippets.

Created September 18, 2019 11:51
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
const STATIC_DATA = [
self.addEventListener('install', function(e) {
console.log('[ServiceWorker] Install');
e.waitUntil('cache_v1').then(function(cache) {
return cache.addAll(STATIC_DATA);
self.addEventListener('activate', function(e) {
console.log('[ServiceWorker] Activate');
self.addEventListener('fetch', function(event) {
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment