fetch keepalive

A fetch option, keepalive: true, that lets a small request keep going after the page that started it has been closed or navigated away.

In more detail

It is the modern way to send analytics on page exit, replacing navigator.sendBeacon() while allowing any method and headers. The total body size of pending keepalive requests is limited to 64 kilobytes.

Example

fetch('/analytics', { method: 'POST', body, keepalive: true })

Related terms

Taught in

References