简体   繁体   English

Angular PWA ngsw-config updateMode——它何时会在用户的 PWA 上更新?

[英]Angular PWA ngsw-config updateMode -- when will it update on user's PWA?

We recently deployed a production app using Ionic + Angular PWA.我们最近使用 Ionic + Angular PWA 部署了一个生产应用程序。 Unfortunately we didn't set updatemode for assets *.js & *.html.不幸的是,我们没有为资产 *.js 和 *.html 设置更新模式。 We have deployed a new version of ngsw-config and ngsw.json which includes a method for updating assets.我们已经部署了新版本的 ngsw-config 和 ngsw.json,其中包括更新资产的方法。

If a user has already installed our app on their phone (ie shortcut on home screen) -> how long will it take for their ngsw-config or ngsw.json to update?如果用户已经在他们的手机上安装了我们的应用程序(即主屏幕上的快捷方式)-> 他们的 ngsw-config 或 ngsw.json 需要多长时间更新?

Will it update automatically?会自动更新吗?

As per https://angular.io/guide/service-worker-devops#update-checks :根据https://angular.io/guide/service-worker-devops#update-checks

Every time the user opens or refreshes the application, the Angular service worker checks for updates to the app by looking for updates to the ngsw.json manifest.每次用户打开或刷新应用程序时,Angular Service Worker 都会通过查找 ngsw.json 清单的更新来检查应用程序的更新。 If an update is found, it is downloaded and cached automatically, and will be served the next time the application is loaded.如果找到更新,它会自动下载并缓存,并在下次加载应用程序时提供。

This means that the next time* your user opens the app, he should get the updated content/app because a new version of ngsw.json is available in the server.这意味着下次*您的用户打开应用程序时,他应该获得更新的内容/应用程序,因为服务器中提供了新版本的ngsw.json

Side note: I have not tried it myself.旁注:我自己没有尝试过。 The only thing I am unsure of is whether the service worker always fetches the new ngsw.json file even if you explicitly set a Cache-Control: max-age... header on ngsw.json file.我唯一不确定的是,即使您在ngsw.json文件上明确设置了Cache-Control: max-age...标头,Service Worker 是否总是获取新的ngsw.json文件。 I think it will as Angular boasts a strong guarantee of app integrity.我认为它会因为 Angular 拥有对应用程序完整性的有力保证 But, I would recommend you to experiment with it beforehand.但是,我建议您事先尝试一下。

* (Note on "next time") If a user already "added to home screen" the previous version, when he opens the app again, the browser still renders the old app even if the new version is now available. *(注意“下次”)如果用户已经“添加到主屏幕”上一个版本,当他再次打开应用程序时,即使新版本现在可用,浏览器仍然呈现旧应用程序。 This is because the service worker checks for updates to ngsw.json during this time and downloading the updated versions in the background.这是因为 Service Worker期间检查ngsw.json的更新并在后台下载更新的版本。 If the user closes and opens the app the second time, that is when the new version will be actually rendered.如果用户第二次关闭并打开应用程序,则新版本将实际呈现。 I have read somewhere (but I forget where) that a "new version is available, would you like to refresh" message can be shown during the first time a user opens the app after a new version is available, but that is out of scope of this question, so I won't dig into that.我在某处(但我忘记在哪里)读到,在新版本可用后用户第一次打开应用程序时,可以显示“新版本可用,您要刷新吗”消息,但这超出了范围这个问题,所以我不会深入研究。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM