Skip to content

Instantly share code, notes, and snippets.

View megacarlossm's full-sized avatar
🏠
Working from home

Carlos Eduardo Salazar Mori megacarlossm

🏠
Working from home
View GitHub Profile
@megacarlossm
megacarlossm / service-worker.js
Created September 28, 2020 12:31 — forked from JMPerez/service-worker.js
An example of a service worker for serving network first, cache second
// the cache version gets updated every time there is a new deployment
const CACHE_VERSION = 10;
const CURRENT_CACHE = `main-${CACHE_VERSION}`;
// these are the routes we are going to cache for offline support
const cacheFiles = ['/', '/about-me/', '/projects/', '/offline/'];
// on activation we clean up the previously registered service workers
self.addEventListener('activate', evt =>
evt.waitUntil(