We discussed read-through caching in the previous recipe. Let's quickly recap what read-through caching is. After a service worker gains control of the page, the first time a new resource has been requested, the response will be stored in the service worker cache.
In this recipe, we are utilizing this feature to store any failed Google Analytics/collect pings in an IndexedDb database. IndexedDb is a client-side, user-specific storage specification that allows us to store data in an indexed manner, and is backed by an API that provides search capabilities. So any time the service worker starts up, any saved Google Analytics pings will be replayed.
To learn more about IndexedDb you can follow these links:
This will give you a great platform to perform transactions offline, regardless of connectivity and availability.