[Webkit-unassigned] [Bug 199110] PWA in iOS use old assets after publish new servicerWorker/assets
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Fri Jun 21 14:27:00 PDT 2019
https://bugs.webkit.org/show_bug.cgi?id=199110
Etienne Maheu <etienne.maheu at randstad.ca> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |etienne.maheu at randstad.ca
--- Comment #4 from Etienne Maheu <etienne.maheu at randstad.ca> ---
Let us continue this discussion in this thread instead.
=================================================================
> Yes, I understand this problem.
>
> The problem you mentioned that you discussed in the communiques, I also encountered these discussions but don't work.
>
> The skipWaiting function does not work on iOS equal it works correctly on all. Were you able to make updates work correctly on iOS only with skipWaiting?
>
> We applied the solution using skipWaiting combining with the worker's controllerchange to update, but it does not work in any way on iOS and so we opened the BUG I mentioned above.
>
> I would be happy to see 1 example of everything working on iOS, but using the implementations of workbox, create-react-app, vue-cli, google... none worked.
I think I understand your problem better now. What you are describing happens because iOS will never unload the PWA, so even with "skipWaiting" set, which will refresh the cache properly, the app itself never gets to restart.
Assuming that you are using the "skipWaiting" trick, you will also want to implement this code in your head html tag: https://gist.github.com/kawazoe/fa3b5a3c998d16871ffb9e2fd721cb4b
The gist contain a minified and unminified version of a script that will detect application version changes and automatically trigger a page refresh when they happen.
This code parses the content of the "service-worker.js" file that is generated by Google Workbox to look for a file called "precache-manifest.*.js". The star here correspond to a unique hash that will change every time your app updates. This script uses this hash as a site version and stores it as "pmv" in local storage. If the version is different from the version stored in localstorage, this script will refresh the page. This works because the "service-worker.js" file is requested in a way that will always bypass caches.
This is truly a hack, a workaround, to get this working on iOS. Unfortunately, it can make the app "blink" once after an update since your PWA will not wait for this call to finish before loading. Also, you will need to either reboot (if you find it to work) or clear the safari cache after you make this change to ensure that the html file that your device cached include the fix.
I am running this in production on one of my apps and it has been working fine for over 6 months now.
--
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20190621/45c7f872/attachment.html>
More information about the webkit-unassigned
mailing list