简体   繁体   中英

How to force Service-worker to request route from network after loading it from cache?

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 :)

如果您使用toolbox.fastest ,它将获取缓存响应或网络响应(以最快的速度(几乎肯定总是缓存)),然后使用网络响应更新缓存。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM