Skip to main content

cache-manager

Central client utility for cache age policy (max 12 hours), service worker RPC, storage wipes, and avatar localStorage hygiene.

Policy​

  • MAX_CACHE_AGE — 12h cap for all TTLs.
  • CACHE_TTLS — static, dynamic, api, images, pages (each clamped to max age).

Service worker​

APIPurpose
sendServiceWorkerMessagePostMessage + 10s timeout
getCacheInfo / refreshCache / cleanupOldCachesSW-backed cache ops
registerServiceWorkerRegistration helper
isServiceWorkerActiveController present

Cleanup​

  • clearAllCaches, clearAllBrowserStorage, performCompleteCleanup — coordinated purge (preserves radio IndexedDB via deleteNonPreservedIndexedDatabases).
  • cleanupServiceWorkers — unregister SWs.
  • clearRouteFilters — route filter localStorage key.

Maintenance​

  • shouldPerformDailyRefresh / markDailyRefreshCompleted — daily refresh gate.
  • formatCacheAge, isCacheExpired — UI helpers.
  • clearOldAvatarCache, getAvatarCacheSize, isAvatarCacheNearQuota — avatar blob cache.

Sources: src/lib/utils/cache-manager.ts