Skip to Content
Platform.Ontology

Page Lifecycle and back/forward cache

Tells a page when it is frozen, discarded or restored from the back/forward cache.

Gets silentlySpeed and timingLifecycleWeb browsersWhile you use itAfter you leave the site

In one line

Can tell when your tab sleeps, is discarded or returns from the Back button

Tells a page when it is frozen, discarded or restored from the back/forward cache.

A site can see when a tab goes to sleep, was discarded to free memory, or came back instantly from the back button, which reveals how you navigate and how much memory the device has.

What it can and can't do

What the user does: You switch away, leave the tab idle, or press Back

It can

  • Learn when a tab is frozen or put to sleep
  • Learn when a tab was discarded to free memory
  • Learn when a page came back instantly from the Back button
  • Guess how you move between pages and how much memory your device has

It cannot

  • See which other tabs you have open
  • See what you did in other tabs
  • Ask permission first
  • Keep running after the tab is discarded

How it differs between platforms: Chrome and Edge support the full set. Firefox and Safari support parts of it.

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported682018-07-24None
EdgeSupported792020-01-15None
FirefoxNot supportedNot availableNot listedNone
SafariNot supportedNot availableNot listedNone
Safari on iPhoneNot supportedNot availableNot listedNone
Chrome on AndroidSupported682018-07-24None
Samsung InternetSupported10.02019-08-22None

How a site asks for it

APIpageshow, pagehide, freeze, resume, document.wasDiscarded, visibilitychange
Browser compat keysapi.Document.freeze_event
api.Document.wasDiscarded
api.Window.pageshow_event
How access is grantednone
What the user seesNone (no browser prompt)
Needs a secure context (HTTPS)No
Needs a user gestureNo
Activationnone
How long it lastsPer page; state follows the lifecycle events until the page is discarded
How to take it backNothing to revoke (no permission is stored)
Inside an iframePer frame; the same events fire in iframes

Typical flow

  1. Browser freezes or discards a hidden tab
  2. Page receives freeze or pagehide (persisted=true for bfcache)
  3. On return the page receives resume or pageshow
  4. document.wasDiscarded is true after a discard reload

Data you get

Shape: none

No individual data fields. The signal is the access itself.

Technical limits

  • freeze, resume and wasDiscarded are Chromium only (Chrome 68); pagehide and pageshow work everywhere
  • Pages in the back/forward cache cannot run timers, network or most APIs while frozen
  • unload handlers block bfcache in several browsers; Chrome has been phasing unload out gradually (check current status)
  • Chrome discards background tabs under memory pressure; the time before freeze is not fixed
  • beacon via visibilitychange is the reliable last chance to send data

The story

What it is

A page learns when it is frozen, discarded or restored from the back and forward cache.

For you

You see it as an instant Back button, and tabs that come back right where you left them. Behind the scenes the page is frozen when hidden and woken up when you return.

For makers

Makers use it to save your work before a tab is frozen and to make the Back button feel instant, which helps sales and speed scores. It also lets ad and analytics scripts know when to send their last report.

Where you see it

TypeExampleApps
shoppingYou press Back from a product page and the search results appear instantly with your scroll position.Amazon, eBay
productivityA web editor saves your draft the moment the tab is frozen, so nothing is lost.Google Docs, Notion
gamesA browser game pauses and keeps its state when the tab is frozen, then restores it when you return.None named
analyticsAn analytics script sends its last data when the page is hidden, since the unload event is not reliable.Google Analytics
videoA video site remembers your playback spot when the tab is discarded and reloaded.YouTube
messagingA chat app reconnects and catches up on messages when a tab is restored from the cache.Slack, Discord
newsA news site refreshes stale content when a cached page is restored, so you do not read old headlines.None named

Risks

  • Stale data if not handled
  • Hidden state saved

What the platform says

Good uses and abuse

Legitimate uses

  • Saving state before tabs are frozen
  • Restoring app UI after bfcache restore
  • Analytics that send on pagehide

Known abuse

  • Measuring device memory pressure and tab habits
  • Sending data as the tab hides

Scores

ScoreValueMeaning
Sensitivity1 of 5How revealing the data is
Utility4 of 5How useful it is to honest apps
Friction0 of 5How much the user has to do
Fingerprint bits2Rough identifying entropy, when known

History

  • 2018-07, Chrome 68: Page Lifecycle API (freeze, resume, wasDiscarded)
  • 2021-11, Chrome 96: Desktop back/forward cache enabled for most users

Sources

How well checked: Based on official documentation.

On this page