渐进式Web应用程序什么时候更新其清单文件? [英] When does a progressive web app update on making a change to its manifest file?

查看:74
本文介绍了渐进式Web应用程序什么时候更新其清单文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个渐进式Web应用程序,我希望对其清单文件进行更改,例如对其start_url,范围,图标,名称和short_name进行更改.我想知道,何时对渐进式Web应用程序进行更新是在更改其清单之后?我尝试以下操作来强制在Chrome浏览器上更新Web应用:

I have a progressive web app and I wish to make changes to its manifest file like a change to its start_url, scope, icon, name and short_name. I wish to know, when is it that the updates to the progressive web app take place after making a change to its manifest? I tried the following to force update the web app on Chrome browser:

  • 启动WebAPK
  • 关闭WebAPK
  • 修改Web清单
  • 将Android的系统时间提前3天.在我的设备上:设置>系统>日期和时间;时间>设置日期
  • 启动WebAPK,等待几秒钟
  • 运行 adb shell dumpsys jobscheduler |JOB.* 91. * org.chromium.components.background_task_scheduler.BackgroundTaskJobService
  • 检查输出是否为空
  • 关闭WebAPK
  • 运行 adb shell cmd jobscheduler运行-f com.android.chrome 91 强制更新

但是,我想知道在更改清单文件后更新Web应用程序的真正标准是什么?请有人可以附加支持该代码段的代码段,这可能是Chrome实施方式所特有的吗?

However, I wish to know what is the real criteria for update to the web app after a change to the manifest file is done? Please can someone attach a code snippet supporting the same, which may be specific to how Chrome implements it?

推荐答案

我进行了深入研究,以了解对清单文件进行更改时更新Web应用程序的确切标准是什么,并且我能够找到相关的源代码在具有更新逻辑的铬代码库中.根据最新的铬源代码更改, https://chromium-review.googlesource.com/c/chromium/src/+/1635860 ,更新间隔设置为1天( 99%,应用可能更频繁地更新)和30天( 1%的情况下,应用更新频率可能较低).以前,将其设置为3天(99%的情况)和30天(1%的情况).此外,谷歌有一份官方文档 https://developers.google.com/web/fundamentals/integration/webapks#update-webapk 其中说:

I did a deep dive, to know what exactly is the criteria for update of web app on changes to manifest file and I was able to find the relevant source code in the chromium code base which had the update logic. According to the latest chromium source code changes https://chromium-review.googlesource.com/c/chromium/src/+/1635860 , the update interval is set to 1 day (99% cases, where the apps may update more frequently) and 30 days (1% cases where the apps may update less frequently). Previously, it was set to 3 days ( 99% cases) and 30 days ( 1% cases). Also, there is an official documentation by Google https://developers.google.com/web/fundamentals/integration/webapks#update-webapk which says :

Chrome会定期将本地安装的清单与从网络获取的清单副本进行比较.如果清单中将PWA添加到主屏幕所需的清单中的任何属性在网络副本中已更改,Chrome都会请求更新的WebAPK,以反映这些新值.有许多规则可控制如何触发这些更新检查:

Chrome will periodically compare the locally installed manifest against a copy of the manifest fetched from the network. If any of the properties in the manifest required to add the PWA to the home screen have changed in the network copy, Chrome will request an updated WebAPK, reflecting those new values. There are a number of rules that govern how these update checks are triggered:

  • 更新检查仅在启动WebAPK时进行.直接启动Chrome不会触发给定WebAPK的更新检查.
  • Chrome每1天或每30天检查一次更新.每天大部分时间都会检查更新.在更新服务器无法提供更新的极少数情况下,它将切换到30天间隔.
  • 清除Chrome的数据(通过Android设置中的清除所有数据")会重置更新计时器.
  • 只有在Web清单URL不变的情况下,Chrome才会更新WebAPK.如果将网页从引用/manifest.json更改为引用/manifest2.json,则WebAPK将不再更新.(不要这样做!)
  • 仅当WebAPK未运行时,Chrome才会更新WebAPK.如果WebAPK持续运行,将其移动到后台是不够的.
  • 仅更新由正式版Chrome(稳定版/测试版/开发版/金丝雀)创建的WebAPK.它不适用于Chromium(org.chromium.chrome).
  • 更新检查可能会延迟,直到插入设备并建立WiFi连接为止.

已经验证过了.

负责此更新的代码流如下:

The code flow responsible for this update is given by follows :

  • Whenever, there is an update to the manifest file at the same origin, an update task is scheduled in the background service by the WebApkUpdateTask the link of which is given as follows : https://cs.chromium.org/chromium/src/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateTask.java .
  • This update task is managed by the WebApkUpdateManager , the link of which is as follows : https://cs.chromium.org/chromium/src/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java?sq=package:chromium&dr=CSs&g=0
  • The check for updates interval is done by the WebappDataStorage , the link of which is as follows : https://chromium.googlesource.com/chromium/src/+/652f0ba0d8d29ba7508654bf20172d3c83a784fb/chrome/ android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java (https://chromium.googlesource.com/chromium/src/+/652f0ba0d8d29ba7508654bf20172d3c83a784fb/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebappDataStorage.java)

这篇关于渐进式Web应用程序什么时候更新其清单文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆