feat: complete application updates
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
const CACHE_NAME = 'nademitex-admin-v1'
|
||||
|
||||
self.addEventListener('install', () => {
|
||||
self.skipWaiting()
|
||||
})
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(self.clients.claim())
|
||||
})
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
if (event.request.method !== 'GET') return
|
||||
|
||||
const url = new URL(event.request.url)
|
||||
if (url.origin !== self.location.origin || url.pathname.includes('/server/api')) return
|
||||
|
||||
event.respondWith(
|
||||
fetch(event.request)
|
||||
.then((response) => {
|
||||
const copy = response.clone()
|
||||
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, copy))
|
||||
return response
|
||||
})
|
||||
.catch(() => caches.match(event.request)),
|
||||
)
|
||||
})
|
||||
Reference in New Issue
Block a user