Sha256: 8732196ee7ae5b66e17dcf7b116f39279675981dec7861e54a2629cae3249253
Contents?: true
Size: 934 Bytes
Versions: 3
Compression:
Stored size: 934 Bytes
Contents
const CACHE_NAME = 'v1' const urlsToCache = ['/'] const self = this // Install SW self.addEventListener('install', (event) => { event.waitUntil( caches.open(CACHE_NAME).then((cache) => { console.log('Opened cache') return cache.addAll(urlsToCache) }) ) }) // Listen for requests self.addEventListener('fetch', (event) => { event.respondWith( caches.match(event.request).then(() => { return fetch(event.request).catch(() => caches.match(urlsToCache)) }) ) }) // Activate the SW self.addEventListener('activate', (event) => { const cacheWhitelist = [] cacheWhitelist.push(CACHE_NAME) event.waitUntil( caches.keys().then((cacheNames) => Promise.all( cacheNames.map((cacheName) => { if (!cacheWhitelist.includes(cacheName)) { return caches.delete(cacheName) } }) ) ) ) })
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
word-games-theme-0.1.2 | assets/js/serviceworker.js |
word-games-theme-0.1.1 | assets/js/serviceworker.js |
appscms-tools-theme-1.0.3 | assets/js/serviceworker.js |