feat(serviceworker): Add server-driven service worker cache invalidation and TypedSocket integration

This commit is contained in:
2025-12-04 11:46:55 +00:00
parent 98eae1e79a
commit 031eb78288
7 changed files with 107 additions and 5 deletions

View File

@@ -75,8 +75,17 @@ export class ReloadChecker {
this.infoscreen.setText(reloadText);
if (globalThis.globalSw?.purgeCache) {
await globalThis.globalSw.purgeCache();
} else if ('caches' in window) {
// Fallback: clear caches via Cache API when service worker client isn't initialized
try {
const cacheKeys = await caches.keys();
await Promise.all(cacheKeys.map(key => caches.delete(key)));
logger.log('ok', 'Cleared caches via Cache API fallback');
} catch (err) {
logger.log('warn', `Failed to clear caches via Cache API: ${err}`);
}
} else {
console.log('globalThis.globalSw not found...');
console.log('globalThis.globalSw not found and Cache API not available...');
}
this.infoscreen.setText(`cleaned caches`);
await plugins.smartdelay.delayFor(200);