mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-18 03:54:17 +02:00
Force-clear service worker and caches on SpoolBuddy kiosk load
Just unregistering the SW wasn't enough — the old SW still controlled the page for that load. Now detects if any SW exists, nukes all SWs and caches, then reloads once to get a clean fetch from the server. Subsequent loads skip this since no SW is registered.
This commit is contained in:
+7
-2
@@ -32,9 +32,14 @@
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
if (location.pathname.startsWith('/spoolbuddy')) {
|
||||
// Kiosk mode — unregister any existing SW to avoid stale cache
|
||||
// Kiosk mode — nuke SW and all caches, then reload once to get clean state
|
||||
navigator.serviceWorker.getRegistrations().then((regs) => {
|
||||
regs.forEach((r) => r.unregister());
|
||||
if (regs.length > 0) {
|
||||
Promise.all([
|
||||
...regs.map((r) => r.unregister()),
|
||||
caches.keys().then((names) => Promise.all(names.map((n) => caches.delete(n)))),
|
||||
]).then(() => location.reload());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.addEventListener('load', () => {
|
||||
|
||||
+7
-2
@@ -33,9 +33,14 @@
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
if (location.pathname.startsWith('/spoolbuddy')) {
|
||||
// Kiosk mode — unregister any existing SW to avoid stale cache
|
||||
// Kiosk mode — nuke SW and all caches, then reload once to get clean state
|
||||
navigator.serviceWorker.getRegistrations().then((regs) => {
|
||||
regs.forEach((r) => r.unregister());
|
||||
if (regs.length > 0) {
|
||||
Promise.all([
|
||||
...regs.map((r) => r.unregister()),
|
||||
caches.keys().then((names) => Promise.all(names.map((n) => caches.delete(n)))),
|
||||
]).then(() => location.reload());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.addEventListener('load', () => {
|
||||
|
||||
Reference in New Issue
Block a user