feat: pwa functionality
This commit is contained in:
20
static/sw.js
Normal file
20
static/sw.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// static/sw.js
|
||||
const CACHE_NAME = 'madplaner-install';
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
// Clear out any old caches from previous versions
|
||||
event.waitUntil(
|
||||
caches.keys().then((names) => {
|
||||
return Promise.all(names.map(name => caches.delete(name)));
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
// Network-only fetch: No caching, just live data
|
||||
self.addEventListener('fetch', (event) => {
|
||||
event.respondWith(fetch(event.request));
|
||||
});
|
||||
Reference in New Issue
Block a user