On background sync
A more advanced caching pattern would be to use the Background Sync API. We'll talk about this in more detail in a later chapter.
The core idea is to wrap all of your network request in a background sync wrapper. Here, you would create a request tag and cue it up to be processed as soon as the network is available.
This adds a new layer of complexity to using the service worker fetch, but can be very valuable if you need to maintain an asynchronous dataset with the server.
If you are connected to the network, any request passed to the Background Sync API will immediately be executed as normal. If you are not connected, it's added to a queue and executed when the device regains connectivity. The following image shows the ...
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