我在使用'workbox.strategies.staleWhileRevalidate‘时遇到问题,我无法通过响应获得更新的数据。有没有办法使用这种策略在每次请求时更新数据?我也使用broadcastUpdate检查标题,但当我使用不同的终端登录时,它会显示旧数据。我希望我的索引数据库应该更新每个请求和dom显示为每个更新的响应。
workbox.routing.registerRoute(
new RegExp('xy/xyzAPI/api'),
workbox.strategies.staleWhileRevalidate({
cacheName: 'api-url',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 20,
maxAgeSeconds: 24 * 60 * 60
}),
new workbox.broadcastUpdate.Plugin('api-url', {
headersToCheck: ['date'],
})
]
}));发布于 2018-10-17 17:26:06
在插件中,请删除或缩短工作箱过期时间
workbox.routing.registerRoute(
new RegExp('xy/xyzAPI/api'),
workbox.strategies.staleWhileRevalidate({
cacheName: 'api-url',
plugins: [
new workbox.expiration.Plugin({
maxEntries: 20,
}),
new workbox.broadcastUpdate.Plugin('api-url', {
headersToCheck: ['date'],
})
]
}));https://stackoverflow.com/questions/52850320
复制相似问题