v149 · Service Workers · Navigation

History State Manager

One of the key use cases for Request.isReloadNavigation: a service worker that preserves form state and scroll position across back/forward navigations (restore from cache) while always fetching fresh data on explicit reloads. This simulator shows the decision tree across a three-page flow.

/ (home)
/products
/products/42
// Navigation events logged here…

On reload (isReloadNavigation: true)

SW bypasses cache entirely. Fetches fresh from network, updates cache. Form state is reset — user explicitly asked for a fresh copy.

On normal navigation (isReloadNavigation: false)

SW serves from cache if available (cache-first strategy). Preserves scroll position and form state from history state object.

Back/forward navigation

Browser restores the previous page from BFCache or history. SW uses cache-first. State is restored exactly as the user left it.

SW code pattern

if (req.isReloadNavigation) { return fetch(req, { cache: 'no-cache' }); }
else { return caches.match(req) || fetch(req); }

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗