Background Sync API
A service worker API that defers a task until the device has a working connection, then fires a sync event to run it, even if the page has been closed.
In more detail
The page stores pending changes in IndexedDB and registers a sync tag; when the connection returns the service worker's sync handler sends them. It is currently supported mainly in Chromium-based browsers, so keep a fallback.
Related terms
- service worker — A script the browser runs in the background, separate from pages, that can intercept a site's network requests and act as a programmable proxy.
- outbox — A local queue of changes waiting to be sent to the server, drained when the connection allows.
- IndexedDB — The browser's built-in asynchronous, transactional database for storing large amounts of structured data, including files and binary data.
- offline — Without a working network connection; an offline-capable web app keeps working from local data and caches.
Taught in
- Background Sync, Push Notifications And PWA Manifests — Frontend Architecture & Web Platform