我正在尝试从sw-toolbox移动到Workbox,我需要做的一件事是缓存来自不同服务器上的API url的所有查询字符串结果,我尝试了一些代码,但还没有成功。
这是我最新的尝试:
workbox.routing.registerRoute(
'https://domain.example-third-party.co.uk/API/' + '(.*)',
workbox.strategies.cacheFirst({
cacheName: 'extra',
plugins: [
new workbox.cacheableResponse.Plugin({
statuses: [0, 200]
})
]
})
);顺便说一句,我已经试过没有'(.*)‘了。
发布于 2018-03-10 00:31:36
workbox.routing.registerRoute(
new RegExp('^https://domain\.example-third-party\.co\.uk/API/'),
workbox.strategies.cacheFirst({
cacheName: 'extra',
plugins: [
new workbox.cacheableResponse.Plugin({
statuses: [0, 200]
})
]
})
);在https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw#migrate_from_hand-crafted_sw-toolbox_to_workbox-sw上有一个您可能已经见过的示例,以及https://developers.google.com/web/tools/workbox/guides/route-requests上的Workbox v3中路由的一般指南
https://stackoverflow.com/questions/49185299
复制相似问题