强制刷新 manifest.json 以下载新的 PWA
Force refresh of manifest.json to download new PWA
我有一个 start_url 设置为 /mysite
。现在,我更新了清单,将 start_url 设置为 /mysite?tracking=ga
,以便查看应用的安装情况。
无论如何,我这辈子都不知道如何强制下载新的应用程序,该应用程序仍然指向旧的 start_url
。我知道如何更新服务工作者,从而更新缓存 API 或任何其他缓存,但没有可靠的方法来强制刷新 manifest.json
并因此强制重新下载 apk。即使当我删除 apk 并通过“添加到主屏幕”下载新应用程序时,它也指向旧的 `start_url。我的理解是每个清单都需要一个新的 apk。
*更新:在我更新清单 theme_color 的地方进行了多次测试,查看更改的唯一方法是卸载应用程序并完全清除 Chrome 缓存和数据,然后通过“重新安装”添加到主屏幕”提示。
改变<link rel="manifest" href="manifest.json">
收件人:<link rel="manifest" href="manifest.json?v=2">
在您网站页面的头部文档中。
这将替换新清单文件的缓存。
参考这个link。
引用link,
Updates on desktop Chrome
When the PWA is launched, or opened in a browser tab, Chrome determines the last time the local manifest was checked for changes. If the manifest hasn't been checked since the browser last started, or it hasn't been checked in the last 24 hours, Chrome will make a network request for the manifest, then compare it against the local copy.
If select properties in the manifest have changed (see list below), Chrome queues the new manifest, and after all windows have been closed, installs it. Once installed, all fields from the new manifest (except name, short_name, start_url and icons) are updated.
Which properties will trigger an update?
display
scope
shortcuts
theme_color
file_handlers
Updates on Chrome for Android
When the PWA is launched, Chrome determines the last time the local manifest was checked for changes. If the manifest hasn't been checked in the last 24 hours, Chrome will schedule a network request for the manifest, then compare it against the local copy.
If select properties in the manifest have changed (see list below), Chrome queues the new manifest, and after all windows of the PWA have been closed, the device is plugged in, and connected to WiFi, Chrome requests an updated WebAPK from the server. Once updated, all fields from the new manifest are used.
Which properties will trigger an update?
background_color
display
orientation
scope
shortcuts
start_url
theme_color
web_share_target
In most cases, changes should be reflected within a day or two of the PWA being launched, after the manifest has been updated.
我做了一些测试,其中包括 (1) 卸载当前的 PWA,(2) 清除浏览器数据和缓存,以及 (3) 重新安装似乎强制刷新的 PWA。但是,当然这仅用于测试目的 - 我想您将无法向所有应用程序用户发出相同的指示。
除了通过 link 对文档给出的答案之外,我想在
Chrome 75 及更早版本,WebAPK 更新发生在 3 day intervals. On Chrome 76 (July 2019) and later, the update interval was reduced to 1 day。当计时器到期时,应用程序将检查 manifest
是否需要更新 - 这将在应用程序启动时完成。
以下是更新的原因:
enum UpdateReason {
NONE = 1;
OLD_SHELL_APK = 2;
PRIMARY_ICON_HASH_DIFFERS = 3;
SCOPE_DIFFERS = 5;
START_URL_DIFFERS = 6; // OP's scenario
SHORT_NAME_DIFFERS = 7;
NAME_DIFFERS = 8;
BACKGROUND_COLOR_DIFFERS = 9;
THEME_COLOR_DIFFERS = 10;
ORIENTATION_DIFFERS = 11;
DISPLAY_MODE_DIFFERS = 12;
WEB_SHARE_TARGET_DIFFERS = 13;
MANUALLY_TRIGGERED = 14;
PRIMARY_ICON_MASKABLE_DIFFERS = 15;
SHORTCUTS_DIFFER = 16;
SPLASH_ICON_HASH_DIFFERS = 17;
reserved 4;
}
快速简单!
首先在网站上找到 manifest.json
文件,例如 domain.com/manifest.json
。
然后进行硬刷新(在电脑上按 ctrl
和 refresh
按钮)。
我不是 100% 确定它是否适用于已安装的 WebApp,但理论上它应该适用于所有设备上已安装的 WebApp。
我有一个 start_url 设置为 /mysite
。现在,我更新了清单,将 start_url 设置为 /mysite?tracking=ga
,以便查看应用的安装情况。
无论如何,我这辈子都不知道如何强制下载新的应用程序,该应用程序仍然指向旧的 start_url
。我知道如何更新服务工作者,从而更新缓存 API 或任何其他缓存,但没有可靠的方法来强制刷新 manifest.json
并因此强制重新下载 apk。即使当我删除 apk 并通过“添加到主屏幕”下载新应用程序时,它也指向旧的 `start_url。我的理解是每个清单都需要一个新的 apk。
*更新:在我更新清单 theme_color 的地方进行了多次测试,查看更改的唯一方法是卸载应用程序并完全清除 Chrome 缓存和数据,然后通过“重新安装”添加到主屏幕”提示。
改变<link rel="manifest" href="manifest.json">
收件人:<link rel="manifest" href="manifest.json?v=2">
在您网站页面的头部文档中。
这将替换新清单文件的缓存。
参考这个link。
引用link,
Updates on desktop Chrome
When the PWA is launched, or opened in a browser tab, Chrome determines the last time the local manifest was checked for changes. If the manifest hasn't been checked since the browser last started, or it hasn't been checked in the last 24 hours, Chrome will make a network request for the manifest, then compare it against the local copy.
If select properties in the manifest have changed (see list below), Chrome queues the new manifest, and after all windows have been closed, installs it. Once installed, all fields from the new manifest (except name, short_name, start_url and icons) are updated.
Which properties will trigger an update?
display
scope
shortcuts
theme_color
file_handlers
Updates on Chrome for Android
When the PWA is launched, Chrome determines the last time the local manifest was checked for changes. If the manifest hasn't been checked in the last 24 hours, Chrome will schedule a network request for the manifest, then compare it against the local copy.
If select properties in the manifest have changed (see list below), Chrome queues the new manifest, and after all windows of the PWA have been closed, the device is plugged in, and connected to WiFi, Chrome requests an updated WebAPK from the server. Once updated, all fields from the new manifest are used.
Which properties will trigger an update?
background_color
display
orientation
scope
shortcuts
start_url
theme_color
web_share_target
In most cases, changes should be reflected within a day or two of the PWA being launched, after the manifest has been updated.
我做了一些测试,其中包括 (1) 卸载当前的 PWA,(2) 清除浏览器数据和缓存,以及 (3) 重新安装似乎强制刷新的 PWA。但是,当然这仅用于测试目的 - 我想您将无法向所有应用程序用户发出相同的指示。
除了通过 link 对文档给出的答案之外,我想在
Chrome 75 及更早版本,WebAPK 更新发生在 3 day intervals. On Chrome 76 (July 2019) and later, the update interval was reduced to 1 day。当计时器到期时,应用程序将检查 manifest
是否需要更新 - 这将在应用程序启动时完成。
以下是更新的原因:
enum UpdateReason {
NONE = 1;
OLD_SHELL_APK = 2;
PRIMARY_ICON_HASH_DIFFERS = 3;
SCOPE_DIFFERS = 5;
START_URL_DIFFERS = 6; // OP's scenario
SHORT_NAME_DIFFERS = 7;
NAME_DIFFERS = 8;
BACKGROUND_COLOR_DIFFERS = 9;
THEME_COLOR_DIFFERS = 10;
ORIENTATION_DIFFERS = 11;
DISPLAY_MODE_DIFFERS = 12;
WEB_SHARE_TARGET_DIFFERS = 13;
MANUALLY_TRIGGERED = 14;
PRIMARY_ICON_MASKABLE_DIFFERS = 15;
SHORTCUTS_DIFFER = 16;
SPLASH_ICON_HASH_DIFFERS = 17;
reserved 4;
}
快速简单!
首先在网站上找到 manifest.json
文件,例如 domain.com/manifest.json
。
然后进行硬刷新(在电脑上按 ctrl
和 refresh
按钮)。
我不是 100% 确定它是否适用于已安装的 WebApp,但理论上它应该适用于所有设备上已安装的 WebApp。