Nic*_*icu 3 google-chrome service-worker angular angular-service-worker
有谁知道角度服务人员是否没有缓存帖子请求?我使用 @angular 5.2.5 将它集成到我的应用程序中,它缓存了一些请求,但其中一些是帖子,而那些他不会缓存的请求,即使它们与我指定的 url 模式匹配。这是我的 ngsw-config.json
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html"
],
"versionedFiles": [
"/*.bundle.css",
"/*.bundle.js",
"/*.chunk.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**"
],
"urls": [
"**/fonts.googleapis.com/**/*",
"**/www.gstatic.com/**/*"
]
}
}
],
"dataGroups": [
{
"name": "api-performance",
"urls": [
"/api/attachments/*"
],
"cacheConfig": {
"maxSize": 200,
"maxAge": "7d",
"timeout": "10s",
"strategy": "performance"
}
},
{
"name": "api-freshness",
"urls": [
"/api/*",
"/api/**/*",
"/api/**/**/*",
"/api/**/**/**/*",
"/api/views/*",
"/api/app-structure",
"/api/workflow/view",
"/api/issues/*",
"/.well-known",
"/certs"
],
"cacheConfig": {
"maxSize": 200,
"maxAge": "2d",
"timeout": "10s",
"strategy": "freshness"
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
添加这只是为了测试,因为 /views 没有缓存,并且这是一个发布请求,我尝试添加通配符来匹配模式,但没有成功"/api/*", "/api/**/*", "/api/**/**/*", "/api/**/**/**/*"。
我在使用 chrome 进行生产构建时测试我的网站时遇到问题,因为对于我们的内部生产环境,我们正在使用自签名认证,有人知道解决方法吗?我尝试了此响应 ,但 chrome 仍然显示错误并且服务工作人员未运行
Angular Service Worker 不会缓存发布请求,在我看来这是一个正确的设计原则。如果您尝试在离线状态下添加记录,并希望在上线时与服务器数据同步,您可以尝试使用 IndexedDb 或 PouchDb(无缝同步的 JavaScript 数据库)。
以下是一些 PouchDB 入门参考文章
| 归档时间: |
|
| 查看次数: |
2473 次 |
| 最近记录: |