Background sync
The service worker cache enables a site to render offline. But that only helps when you have the page and assets available in the cache. What can you do if you need to post data or get uncached pages while offline?
This is where background sync can help. It enables you to register a request that will be fulfilled when the device is back online.
Background sync executes asynchronous tasks in the background, when a device is online. It works by building a queue of requests to fulfill as soon as the device is capable of connecting to the internet.
The way background sync works is you place a network request with a tag, registered with the SyncManager. The platform is responsible for checking if the device is online or offline. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access