【发布时间】:2020-11-10 16:02:30
【问题描述】:
我有一个这样的公共 API 端点:
https://data.weather.gov.hk/weatherAPI/opendata/weather.php?dataType=warnsum&lang=en
我想用服务工作者运行时缓存它的响应。这就是我定义路线的方式:
registerRoute(
new RegExp('.+/weatherAPI/opendata/weather.php?dataType=warnsum&lang=en'),
new StaleWhileRevalidate({
cacheName: 'weatherApi',
plugins: [
new ExpirationPlugin({
maxAgeSeconds: 60 * 60 * 24
}),
new BackgroundSyncPlugin('getWeatherAPI', {
maxRetentionTime: 24 * 60 // Retry for max of 24 Hours (specified in minutes)
})
]
})
)
但是,这不起作用,并且此 url 的响应未保存到缓存中。我想知道查询参数是否会成为这里的问题,或者我是否遗漏了什么?
【问题讨论】:
标签: javascript progressive-web-apps workbox