NSGW。
我正在将Angular 11应用程序部署到Azure Appservice。该应用使用服务工作者。我的用户正在经历缓存问题。我已经通过在index.html上设置高速缓存控制标头的大量将其修复,但是他们仍在遇到问题。我认为这取决于该应用程序不更新,所以我想知道需要使用哪些cache-control标题。我找不到有关服务和Angular App的任何文档。
I'm deploying an Angular 11 app to an Azure AppService. The app uses a Service Worker. My users are experiencing caching issues. I've fixed a lot of these by setting the cache control header on the index.html to no-cahce
, but they're still experiencing issues. I think it's down to the App not updating, so I'm wondering what cache-control headers the nsgw.json and manifest.webmanifest need to be served with? I can't find any documentation about serving and angular app.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在遇到类似问题时也找不到任何文档,所以我检查了什么 angular.io (也是一个Angular App本身)使用为
缓存-Control
:no-Cache
ngsw.json
和pwa-manifest.json
代码>具有max-age = 3600
ngsw-worker.js
max-age = 86400
我不确定为什么
ngsw .json
被允许缓存,但否则这些值似乎是合理的。I could not find any documentation either while having a similar issue, so I checked what angular.io (also an Angular app itself) uses as
cache-control
:no-cache
ngsw.json
andpwa-manifest.json
havemax-age=3600
ngsw-worker.js
hasmax-age=86400
I'm no sure why
ngsw.json
is allowed to be cached, but otherwise these values seem reasonable.这不是一个确定的答案,而是一个提示,可以帮助您使用服务人员配置应用程序的缓存行为。在
ngsw-config.json
中,有一个属性可以控制如何更新缓存的ressources。我看不到您的文件详细信息,但是应该有“ updatemode”:“ prefetch”
。在这里,您可以在应用程序中控制缓存的ressources的行为。 在Angular doc上读取可以传递给>
的值UpdatedMode
。您可以尝试将
UpdateMode
设置为懒惰
。根据文档,
懒惰
:This is not a definitive answer, but a hint that might help you configure the caching behaviour of your app with service workers. in
ngsw-config.json
there is a property to control how to update the cached ressources. I do not see your file details but there should be"updateMode": "prefetch"
. This is where you control the behaviour of your cached ressources in your app. Read on Angular Docs the values that can be passed to theupdatedMode
. You can try to set theupdateMode
tolazy
.According to documentation,
lazy
: