fetch keepalive
A fetch flag that lets the request finish after the page is gone.
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
| Browser | Status | First version | Released | Note |
|---|---|---|---|---|
| Chrome | Supported | 66 | 2018-04-17 | None |
| Edge | Supported | 15 | 2017-04-05 | None |
| Firefox | Supported | 133 | 2024-11-26 | None |
| Safari | Supported | 13 | 2019-09-19 | None |
| Safari on iPhone | Supported | 13 | 2019-09-19 | None |
| Chrome on Android | Supported | 66 | 2018-04-17 | None |
| Samsung Internet | Supported | 9.0 | 2018-09-15 | None |
How a site asks for it
| API | fetch(url, {keepalive: true}) |
| Browser compat keys | api.Request.keepalive |
| How access is granted | none |
| What the user sees | None |
| Needs a secure context (HTTPS) | No |
| Needs a user gesture | No |
| How long it lasts | Until the request completes or fails |
| How to take it back | Clear site data, browser privacy settings |
| Inside an iframe | Not listed |
Data you get
What comes back: Keepalive request
Shape: event
How often: at page exit
| Field | Type | Unit | Range | Precision |
|---|---|---|---|---|
payload | integer | bytes | up to about 65536 | exact |
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
| Type | Example | Apps |
|---|---|---|
| analytics | A news site reports how long you read and how far you scrolled as you close the article. | Chartbeat, Google Analytics |
| games | A browser game sends your final score or a session end event when you close the tab, so progress is not lost. | Wordle, Agar.io |
| productivity | An online editor sends a last autosave while you close the tab, so your last words are saved. | Google Docs, Notion |
| video | A video site sends your watch position when you leave, so the next visit resumes at the same moment. | YouTube, Netflix |
| security | A fraud tool sends a final batch of mouse and typing data when you leave a checkout page. | Sift, HUMAN Security |
| ads | An 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
| Score | Value | Meaning |
|---|---|---|
| Sensitivity | 3 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 | Not rated | Rough identifying entropy, when known |
History
- 2018-04, Chrome 66: Shipped
- 2019-09, Safari 13: Shipped
- 2024-11, Firefox 133: Shipped
Related capabilities
Related
- 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.