feat: initial release of FlockRadar driving app and national transparency directory for flockradar.org
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// Service Worker for FlockRadar Offline Driving & Caching
|
||||
const CACHE_NAME = 'flockradar-v2';
|
||||
const ASSETS_TO_CACHE = [
|
||||
'./',
|
||||
'./index.html',
|
||||
'./css/styles.css',
|
||||
'./js/app.js',
|
||||
'./js/auth.js',
|
||||
'./js/radar.js',
|
||||
'./data/portals.js',
|
||||
'./manifest.json'
|
||||
];
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS_TO_CACHE))
|
||||
);
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', event => {
|
||||
event.waitUntil(
|
||||
caches.keys().then(keys => Promise.all(
|
||||
keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key))
|
||||
))
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', event => {
|
||||
// Network first, fallback to cache
|
||||
event.respondWith(
|
||||
fetch(event.request).catch(() => caches.match(event.request))
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user