← Daily

Concept · No. 044 · November 29, 2026

The back button is free speed until an unload handler breaks it

The back/forward cache restores a page instantly from memory, but the browser decides eligibility silently, and a single analytics listener can turn every back navigation into a full reload.

The idea

When a user navigates away, the browser can keep a complete snapshot of the page in memory: the DOM, the JavaScript heap, scroll position and form state. If the user presses back or forward, that snapshot is resumed instead of rebuilt. No HTML request, no script evaluation, no hydration. That is the back/forward cache, usually called bfcache.

Back and forward navigations are a meaningful share of all navigations, more so on mobile, where people bounce between a list and a detail page constantly. bfcache makes those navigations effectively free.

The catch is that eligibility is decided by the browser, not by you, and it fails quietly. Nothing in your logs says a page was excluded. It just loads the slow way.

An example

A shop has a filtered product list. The user opens a product, then presses back.

With bfcache working, the list appears exactly as it was: filters applied, scrolled to the same card, infinite scroll pages still loaded.

Now someone adds an analytics snippet that flushes events in an unload listener. Chromium treats unload as a blocker, so the list is no longer eligible. The same back press now refetches the HTML, reruns the bundle, rehydrates, and lands at the top of a list that has forgotten its third page of results.

The fix is small: flush on pagehide or visibilitychange with navigator.sendBeacon. But the restored page has its own problem. The header still shows the cart count from before the user added the product. Timers were frozen, not rerun, so nothing refreshed it. The page needs a pageshow listener that checks event.persisted and refetches the cart.

Where it breaks

Restored state is stale by design. Prices, stock, notifications and session state all reflect the moment the user left. A page that showed account details before logout can reappear after logout unless you check the session on restore.

Some features block caching or evict the page, and the exact list differs by browser: unload listeners, open WebSocket connections, in-flight IndexedDB transactions, and Cache-Control: no-store responses have all been exclusion reasons at various times. Third-party scripts are the usual culprit because they add these without anyone reviewing it.

Measurement breaks too. A restore fires no new load, so page view counts and LCP reporting miss it unless you handle pageshow explicitly.

And it is never guaranteed. Browsers evict under memory pressure, so bfcache is an optimisation to earn, not a behaviour to depend on for correctness.

In practice

I would treat bfcache eligibility as a tested property of key pages, not a happy accident.

  • Run the back/forward cache test in the Chrome DevTools Application panel on your list, search and article pages.
  • Remove every unload listener and send Permissions-Policy: unload=() so third-party code cannot add one back.
  • Flush analytics on pagehide or visibilitychange, never on unload.
  • On pageshow with event.persisted true, refresh volatile data, recheck the session, and record a page view.
  • Close sockets and channels on pagehide and reopen them on pageshow.
  • Reserve no-store for pages that are genuinely sensitive, not as a default for anything personalised.
  • In the field, read notRestoredReasons from the navigation timing entry where supported, so regressions show up as data rather than complaints.
Make bfcache eligibility a tested property of your busiest pages, and handle pageshow with persisted so a restored page refreshes what went stale.