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.
If it cannot make the request, the sync places the request in a queue for that tag. The background sync periodically checks the ability to...