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:
Jason Zimdars
2025-09-02 17:24:21 -05:00
parent 05f3604655
commit c3454847a0
+11
View File
@@ -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) ]))