本文由编程笔记#自由互联小编为大家整理,主要介绍了javascript工作箱-服务工作者缓存相关的知识,希望对你有一定的参考价值。 本文由编程笔记#自由互联小编为大家整理,主要介绍了
workbox.routing.registerRoute( new RegExp(/path/to/api/), new workbox.strategies.StaleWhileRevalidate({ cacheName: api-cache, plugins: [ new workbox.cacheableResponse.Plugin({ headers: { X-Is-Cacheable: true, }, }) ] }));workbox.routing.registerRoute( new RegExp(^https://third-party\\.example\\.com/images/), new workbox.strategies.CacheFirst({ cacheName: image-cache, plugins: [ new workbox.cacheableResponse.Plugin({ statuses: [0, 200], }) ] }));
workbox.routing.registerNavigationRoute(/index.html)