When you navigate away, the browser may keep the whole document instead of destroying it: DOM, JavaScript heap, pending timers and promises, all frozen. Back or Forward then reactivates it without a request or a single script re-running.
In HTML terms, unloading decides whether the document stays salvageable. pagehide fires with persisted set to that value; unload fires only when it's false. On restore, pageshow fires with persisted: true, and there's no load and no popstate. Timers resume as if no time had passed.
The spec forces a few cases out (an open WebSocket, a document whose loading was aborted mid-fetch); the rest is engine policy. What kept a page out in Chrome 156 and Firefox 159:
- A
unloadhandler that will run. Firefox runs them, so the page isn't cached. Chrome's docs say that since Chrome 155 handlers don't run unless the page sendsPermissions-Policy: unload=(self); with that header Chrome ran it and didn't cache. window.openerlinks. A window opened bywindow.open()withoutnoopenerwasn't cached in either.Cache-Control: no-store. Firefox didn't cache; Chrome did, then evicted the page when a cookie changed.
Not blockers: beforeunload handlers, an open IndexedDB connection (both evicted the page when another tab upgraded the database) and an open BroadcastChannel (Chrome evicts when a message arrives).
Two jobs follow. Keep pages eligible: no unload, use pagehide; open windows with noopener; close connections other tabs may wait on. And handle restores: in pageshow with persisted, refresh anything that may be stale, like a cart, login state or analytics view.
To see why a page wasn't restored, Chrome has DevTools' Back/forward cache test, PerformanceNavigationTiming.notRestoredReasons (Chrome 125+) and the protocol event Page.backForwardCacheNotUsed. All three are Chrome-only.