【发布时间】:2020-08-20 16:14:31
【问题描述】:
我正在尝试使用 Angular Service Worker,一切正常,除了 dataGroups 不适合我。
这就是我在ngsw-config.json 中的内容:
{
...
"dataGroups": [
{
"name": "api-performance",
"urls": [
"/shipments/**"
],
"cacheConfig": {
"strategy": "performance",
"maxSize": 100,
"maxAge": "3d"
}
}
]
}
在我的网络选项卡中,我看到服务人员总是进行服务器调用,然后回退到缓存。见附图。
请注意,我调用的 API 位于不同的服务器上,localhost 与 some-server:8000,
我尝试了不同的使用不同的 URL:
"/shipments/**"
"/shipments"
"http:some-server:8000/shipments/**" 等,但没有任何效果。
我的环境:
- @angular 5.1.1
- Service-Worker 5.1.2
- Angular-Cli 1.6.0
【问题讨论】:
-
可能是因为你没有使用https? developers.google.com/web/fundamentals/primers/service-workers/…
标签: angular angular-cli angular5 angular-service-worker