CacheStatus
Default export client footer widget for service-worker page caching.
State
CacheInfo: isCached, optional cacheTimestamp, cacheAge, version, cacheVersion, details (SW active, cache count/size, localStorage KB).
Detection
- Opens
idling-app-cache-v1,match(window.location.pathname). - Timestamp:
idling-app-cache-metadata-v1entrymetadata-${url}→cachedAt; elseCache-Timestamp,Cache-Date, ordateheaders. - Scans all cache names for counts; reads
X-App-Version/SW-Cache-Versionfrom first entry when available.
UI
- Live — green indicator when not cached.
- Cached — click text toggles details panel; abbreviated age via
TimestampWithTooltip. - Refresh button ↻ —
REFRESH_CACHEmessage to active SW withMessageChannel, thencache-updatedevent and reload after 500ms; fallbackfetchwithcache: 'no-cache'.
Updates
cache-updatedlistener rechecks status.- 30s interval refreshes
cacheAgestring when cached.
Exports
export default CacheStatus.
Edge cases
- Missing
cachesAPI leavesisCached: false. - Refresh disabled while
isRefreshing.
Sources: src/app/components/cache-status/CacheStatus.tsx