Skip to Content
Platform.Ontology

fetch keepalive

A fetch flag that lets the request finish after the page is gone.

Works without askingTracking across apps and sitesAfter leavingWeb browsersAfter you leave the site

In one line

Can finish sending a request after you leave or close the page

A fetch flag that lets the request finish after the page is gone.

Replaces sendBeacon when a site needs custom headers or methods on exit. The browser holds the request open past unload, with the same 64 KiB cap. Firefox shipped it in version 133 (Nov 2024).

What it can and can't do

What the user does: Nothing. It happens when you close or leave a page that has a pending report

It can

  • Complete a request that was started before you left
  • Send a last report about the visit
  • Send a small amount of data even as the page unloads

It cannot

  • Send a large amount of data, since there is a small size limit
  • Keep running for long after the page is gone
  • Run if the browser or a blocker stops the request
  • Show you a prompt or any sign

Browser support

BrowserStatusFirst versionReleasedNote
ChromeSupported662018-04-17None
EdgeSupported152017-04-05None
FirefoxSupported1332024-11-26None
SafariSupported132019-09-19None
Safari on iPhoneSupported132019-09-19None
Chrome on AndroidSupported662018-04-17None
Samsung InternetSupported9.02018-09-15None

How a site asks for it

APIfetch(url, {keepalive: true})
Browser compat keysapi.Request.keepalive
How access is grantednone
What the user seesNone
Needs a secure context (HTTPS)No
Needs a user gestureNo
How long it lastsUntil the request completes or fails
How to take it backClear site data, browser privacy settings
Inside an iframeNot listed

Data you get

What comes back: Keepalive request
Shape: event
How often: at page exit

FieldTypeUnitRangePrecision
payloadintegerbytesup to about 65536exact

Technical limits

  • About 64 KiB total in flight per page
  • Not available with all request modes
  • Blocked by tracker blockers

The story

What it is

A flag that lets a web request finish even if you close the page.

For you

You never see it. You close a tab or click away, and the page quietly sends one last note that finishes after the page is gone. It might be your time on page or a saved draft.

For makers

Sites need a way to report at exit, when normal requests are cancelled. Keepalive allows custom headers and methods, which sendBeacon does not. The 64 KiB cap limits how much can go.

Where you see it

TypeExampleApps
analyticsA news site reports how long you read and how far you scrolled as you close the article.Chartbeat, Google Analytics
gamesA browser game sends your final score or a session end event when you close the tab, so progress is not lost.Wordle, Agar.io
productivityAn online editor sends a last autosave while you close the tab, so your last words are saved.Google Docs, Notion
videoA video site sends your watch position when you leave, so the next visit resumes at the same moment.YouTube, Netflix
securityA fraud tool sends a final batch of mouse and typing data when you leave a checkout page.Sift, HUMAN Security
adsAn ad tag sends a last viewability report that says how long the ad was on screen.Google Ad Manager

Risks

  • Hard to see or stop
  • Can send data as you leave

What the platform says

  • Mozilla: Request keepalive. Developer docs say keepalive lets a request outlive the page, so a final report can go out as you leave.

Good uses and abuse

Legitimate uses

  • Exit logging with headers

Known abuse

  • Post-visit data exfiltration

Scores

ScoreValueMeaning
Sensitivity3 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 bitsNot ratedRough identifying entropy, when known

History

  • 2018-04, Chrome 66: Shipped
  • 2019-09, Safari 13: Shipped
  • 2024-11, Firefox 133: Shipped
  • navigator.sendBeacon. Can send a small report that the browser delivers even as you leave the page
  • fetchLater. Can queue a report now and have the browser send it later, even after you close

Sources

How well checked: Checked against real behavior.

On this page