Reputation: 6446
I'm using sw-toolbox, which is a library for service-worker provided by Google. I'd like to combine the cacheFirst strategy (see readme in link above) with a fetch from network after successfully loading a content from cache. Is it possible? So for example smth like:
toolbox.router.get('/api/currentUserID',toolbox.cacheFirst).then(fetchFromNetwork());
Many thanks for any help :)
Upvotes: 2
Views: 587
Reputation: 9821
If you use toolbox.fastest that will get the cache response or the network response, which ever is fastest (which will almost certainly always be the cache) and then update the cache with the response from the network.
Upvotes: 6