Caching and conditional requests
Service workers and offline caching
There is more than one caching layer.
Understand the concept
A service worker can intercept scoped fetches and choose network or Cache API responses. Cache API storage does not automatically reproduce ordinary HTTP freshness behaviour; the application needs a strategy. Network-first, cache-first and stale-while-revalidate have different trade-offs.
Old workers and mismatched assets can cause deployment problems. Design versioned caches, activation and cleanup. Personal offline content after logout is a privacy concern; URL-only keys can expose another account’s data.
Service workers require secure contexts, with local-development exceptions that do not justify production HTTP. Inspect worker/storage state separately from the browser HTTP cache. This course does not register a new worker.
Diagnose stale pages after deployment.
Assuming Disable cache removes all offline behaviour.
One topic. Three levels of depth.
Network response ≠ service-worker responseInspect the response source in DevTools.
This page does not send requests to external servers. Messages are readable HTTP/1.1 illustrations, not HTTP/2 or HTTP/3 wire dumps. example.test is reserved for examples. Run commands and JavaScript only in your own test environment; never publish real tokens or cookies.
Try it yourself first.
Should personalised offline account data remain after logout?
Show the solution and explanation
Deliberate retention and isolation policy requiredNot without a deliberate retention/privacy policy; test account isolation.