Bra*_*hel 5 angular angular-service-worker
我将 Angular 5.2.7 与 Angular Service Worker 5.2.7 一起使用。
我想缓存网络服务调用。所以,我在我的 ngsw-config.json 中为 dataGroups 设置了这个配置:
"dataGroups": [{
"name": "tasks-users-api",
"urls": ["/api", "/rest"],
"cacheConfig": {
"strategy": "freshness",
"maxSize": 20000,
"maxAge": "1h",
"timeout": "5s"
}
}]
Run Code Online (Sandbox Code Playgroud)
我尝试缓存这两个 URL:https : //randomuser.me/api/? results =20 ---> 没关系 https://test.moodlecloud.com/webservice/rest/server.php ---> 它是高
第一个按预期缓存。这是一个简单的 GET 服务。第二个不是。这是一个 POST 服务,表单数据作为有效负载发送。
知道有什么问题吗?
Service Worker API不允许 POST/PUT 请求。
在这篇博客文章中,它展示了一个关于如何使用 Indexed Db(由 Roman Gherta 建议)存储 POST/PUT 请求的示例。
Mozilla 资源上也建议使用此解决方案。
| 归档时间: |
|
| 查看次数: |
4472 次 |
| 最近记录: |