如何解决Angular Service Worker无法正确缓存dataGroups URL
我托管了多个来自abc.example.com,xyz.example.com域的站点,但是每个子域都使用相同的URL进行API访问。在这种情况下api.example.com
我已经使用@ angular / pwa配置了一个服务工作者,并且它似乎已在浏览器中正确注册,并且我正在尝试配置“ dataGroups”,但是url和cacheConfigs的组合都不适合我。 例如
从https://api.example.com/Product/ProductSearch?p=abc123或https://api.example.com/Product/ProductAdditionalInformation?p=abc123收到API响应时,这些变体都不会缓存响应
"dataGroups": [
{
"name": "V1","urls": [
"https://api.example.com/Product/ProductSearch","https://api.example.com/Product/ProductAdditionalInformation"
],"cacheConfig": {
"maxSize": 50,"maxAge": "30m"
}
},{
"name": "V2","urls": [
"**/Product/ProductSearch?","**/Product/ProductAdditionalInformation?"
],{
"name": "V3","urls": ["**/Product/**"],{
"name": "V4","urls": ["/Product"],"maxAge": "30m"
}
}
]
我已经在具有完全https支持的登台环境中测试了这些变体
还有其他我想念的东西吗?
解决方法
你能做个闪电战吗?
旁注:在您的cacheConfig对象中添加“策略”
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。