Page Lifecycle and back/forward cache
Tells a page when it is frozen, discarded or restored from the back/forward cache.
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
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 68 | 2018-07-24 | None |
| Edge | Supported | 79 | 2020-01-15 | None |
| Firefox | Not supported | Not available | Not listed | None |
| Safari | Not supported | Not available | Not listed | None |
| Safari on iPhone | Not supported | Not available | Not listed | None |
| Chrome on Android | Supported | 68 | 2018-07-24 | None |
| Samsung Internet | Supported | 10.0 | 2019-08-22 | None |
How a site asks for it
| API | pageshow, pagehide, freeze, resume, document.wasDiscarded, visibilitychange |
| Browser compat keys | api.Document.freeze_eventapi.Document.wasDiscardedapi.Window.pageshow_event |
| How access is granted | none |
| What the user sees | None (no browser prompt) |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| Activation | none |
| How long it lasts | Per page; state follows the lifecycle events until the page is discarded |
| How to take it back | Nothing to revoke (no permission is stored) |
| Inside an iframe | Per frame; the same events fire in iframes |
Typical flow
- Browser freezes or discards a hidden tab
- Page receives freeze or pagehide (persisted=true for bfcache)
- On return the page receives resume or pageshow
- 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
| Type | Example | Apps |
|---|---|---|
| shopping | You press Back from a product page and the search results appear instantly with your scroll position. | Amazon, eBay |
| productivity | A web editor saves your draft the moment the tab is frozen, so nothing is lost. | Google Docs, Notion |
| games | A browser game pauses and keeps its state when the tab is frozen, then restores it when you return. | None named |
| analytics | An analytics script sends its last data when the page is hidden, since the unload event is not reliable. | Google Analytics |
| video | A video site remembers your playback spot when the tab is discarded and reloaded. | YouTube |
| messaging | A chat app reconnects and catches up on messages when a tab is restored from the cache. | Slack, Discord |
| news | A 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
- Google Chrome: Page Lifecycle API. Chrome describes events that tell a page when the browser freezes or discards it to save memory.
- web.dev: Back/forward cache. Google says bfcache makes the Back button instant by keeping a whole page in memory.
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
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 1 of 5 | How revealing the data is |
| Utility | 4 of 5 | How useful it is to honest apps |
| Friction | 0 of 5 | How much the user has to do |
| Fingerprint bits | 2 | Rough 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
Related capabilities
Related
- Beacons and keepalive requests. Can send data to a server as you leave or close the page
- Background tab timer throttling. Can't keep its timers running fast once you switch to another tab
Sources
How well checked: Based on official documentation.