NSGW。

发布于 2025-02-04 21:48:51 字数 194 浏览 6 评论 0原文

我正在将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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

懵少女 2025-02-11 21:48:51

我在遇到类似问题时也找不到任何文档,所以我检查了什么 angular.io (也是一个Angular App本身)使用为缓存-Control

  • HTML页面具有no-Cache
  • ngsw.jsonpwa-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:

  • The HTML page has no-cache
  • ngsw.json and pwa-manifest.json have max-age=3600
  • ngsw-worker.js has max-age=86400

I'm no sure why ngsw.json is allowed to be cached, but otherwise these values seem reasonable.

我的奇迹 2025-02-11 21:48:51

这不是一个确定的答案,而是一个提示,可以帮助您使用服务人员配置应用程序的缓存行为。在ngsw-config.json中,有一个属性可以控制如何更新缓存的ressources。我看不到您的文件详细信息,但是应该有“ updatemode”:“ prefetch”。在这里,您可以在应用程序中控制缓存的ressources的行为。 在Angular doc上读取可以传递给> 的值UpdatedMode。您可以尝试将UpdateMode设置为懒惰

根据文档,懒惰

告诉服务人员不要缓存这些资源。相反,它
将它们视为无需的,然后等到他们再次要求
在更新它们之前。懒惰的更新词仅在
installmode也是懒惰的。

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 the updatedMode. You can try to set the updateMode to lazy.

According to documentation, lazy:

Tells the service worker to not cache those resources. Instead, it
treats them as unrequested and waits until they're requested again
before updating them. An updateMode of lazy is only valid if the
installMode is also lazy.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文