Add a simple method to refresh content when launching or switching tabs
Prevents stale content on load as reported in: https://fizzy.37signals.com/5986089/collections/2/cards/1449
This commit is contained in:
@@ -1,3 +1,14 @@
|
||||
self.addEventListener('fetch', (event) => {
|
||||
if (event.request.method !== 'GET') return
|
||||
|
||||
if (event.request.destination === 'document') {
|
||||
event.respondWith(
|
||||
fetch(event.request, { cache: 'no-cache' })
|
||||
.catch(() => caches.match(event.request))
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
self.addEventListener("push", async (event) => {
|
||||
const data = await event.data.json()
|
||||
event.waitUntil(Promise.all([ showNotification(data), updateBadgeCount(data.options) ]))
|
||||
|
||||
Reference in New Issue
Block a user