lundi 30 mars 2020

Using service workers to both use cache *and* update in background

I understand that ServiceWorkers can grab responses out of cached network requests.

That said, is it possible to have these workers continue to update the cache in the background?

Consider the following scenario: a user logs into an app where they have cached data, and is immediately greeted with "Welcome, <cached_username>!"

Is it be possible for the service worker to continue to make the network request after serving a cache match? The user could've updated their username to new_username on another device, and it would be great to get the UI eventually consistent.

I still want to make network requests, while also utilizing ServiceWorkers for that speedy initial render.




Aucun commentaire:

Enregistrer un commentaire