'Force refresh of manifest.json to download new PWA
I have a start_url set to /mysite
. Now I've updated the manifest to have start_url set to /mysite?tracking=ga
in order to view installs from the app.
Anyway for the life of me I can't figure out how to force a download of the new app, the app is still pointing to the old start_url
. I know how to update a service worker and thus Cache API or any other caches but do not have a reliable method to force a refresh of manifest.json
and thus force a new download of the apk. Even when I delete the apk and download a new app through "Add to Homescreen" it points to the old `start_url. My understanding is that every manifest requires a new apk.
*Update: Did multiple tests where I updated the manifest theme_color and the only way to see the changes is to uninstall the app and clear Chrome cache and data completely, then reinstall through "Add to home screen" prompt.
Solution 1:[1]
Refer this link.
To quote the 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.
Solution 2:[2]
Fast and simple!
First locate manifest.json
file on the site, for example domain.com/manifest.json
.
Then make a hard refresh (on pc press ctrl
and refresh
button).
I'm not 100% sure if it will work on already installed WebApp, but in theory it should work on already installed WebApp on all devices.
Solution 3:[3]
I've done some tests which involved (1) uninstalling the current PWA, (2) clearing the browser data & cache, and (3) re-installing the PWA which seemed to have forced the refresh. However, of course this is only for testing purposes - I imagine you won't be able to instruct all your app users to the same.
In addition to the answer given via link to the docs, I'd like to highlight that on
Chrome 75 and earlier, the WebAPK updates happen on 3 day intervals. On Chrome 76 (July 2019) and later, the update interval was reduced to 1 day. When the timer expires, the App will be due for checking if the manifest
needs updating - which will be done on-launch of the App.
Here are the reasons for updating:
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;
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Ryan M |
Solution 2 | dns_nx |
Solution 3 |