admin管理员组文章数量:1313742
Despite the number of subjects about this, I still cannot find a way to achieve what I want.
I have an Angular PWA application with a Service Worker, and I simply want the index.html not to be cached at all. So that everytime the user refreshes the page (not hard refresh) the app's main document is always fetched from the server.
I don't want to check updates and force refresh after (impacts user experience) or display a prompt to tell the user to refresh.
Here is my ngsw.config.js:
{
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
"index": "/index.html",
"navigationRequestStrategy": "freshness",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/manifest.webmanifest",
"/*.css",
"/*.js"
]
}
},
{
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
]
}
}
]
}
Note that I removed the index.html
from the assetGroups and add the "navigationRequestStrategy": "freshness"
But when I refresh the page, the document is still served from the service worker: network tab screen
I also tried to send the Cache-Control: no-cache
header from my nginx server but it didn't change anything.
The only thing that actually worked was to load so I guess there is a way to make it work, but that doesn't seem a user-friendly solution to me.
本文标签: Angular amp Service Worker prevent indexhtml cachingStack Overflow
版权声明:本文标题:Angular & Service Worker: prevent index.html caching - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741957555a2407075.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论