You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
589 B
27 lines
589 B
import { registerSW } from "virtual:pwa-register"; |
|
|
|
const intervalMS = 60 * 60 * 1000; |
|
|
|
registerSW({ |
|
immediate: true, |
|
onRegisteredSW(swUrl, r) { |
|
if (!r) return; |
|
setInterval(async () => { |
|
if (!(!r.installing && navigator)) return; |
|
|
|
if ("connection" in navigator && !navigator.onLine) return; |
|
|
|
const resp = await fetch(swUrl, { |
|
cache: "no-store", |
|
headers: { |
|
cache: "no-store", |
|
"cache-control": "no-cache", |
|
}, |
|
}); |
|
|
|
if (resp?.status === 200) { |
|
await r.update(); |
|
} |
|
}, intervalMS); |
|
}, |
|
});
|
|
|