Closed mzimmerm closed 8 months ago
Gilad, one comment inline
On Sat, Dec 23, 2023 at 6:11 PM Gilad Bracha @.***> wrote:
@.**** commented on this pull request.
In build.sh https://github.com/newspeaklanguage/newspeak/pull/124#discussion_r1435733318 :
@@ -11,6 +11,20 @@ pushd ../primordialsoup ./build os=emscripten arch=wasm popd
+# Back in 'newspeak'. +# Increase the pwaVersion in the PWA service worker, the newspeak/platforms/webIDE/sw.js +# This is required on every Newspeak build (strictly speaking, +# only on every Newspeak deployment to HTTP server), for the PWA clients +# to refresh all caches. +# Without the pwaVersion increase, PWA clients would not replace +# the cached HopscotchWebIDE.vfuel with the new version, +# unless forced by manual cache clean or similar + +. ./increase-pwa-version.sh
why is this ../increase-pwa-version.sh and not ./increase-pwa-version.sh?
I thought for sure the README.md recommended running the build.sh sourced as '. ./build.sh' .. although I am not able to find that now.
So I just followed the assumption and sourced the script as well: '. ./increase-pwa-version.sh'. I can make the script executable and execute it instead of source-ing it, although I would have to make a minor change: I took the opportunity it is sourced and slipped a return there in one branch, which would only work as sourced (although that branch is unlikely to run anyway, it is a ).
Let me know if you prefer to change the source-ing to executing.
Milan
— Reply to this email directly, view it on GitHub https://github.com/newspeaklanguage/newspeak/pull/124#pullrequestreview-1795505862, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALGQ7GVUL4O6NZYSE7UBE3YK5QKBAVCNFSM6AAAAABBATWUF6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOOJVGUYDKOBWGI . You are receiving this because you authored the thread.Message ID: @.***>
I think this is fine.
How to test this change:
Server / build - Get the latest version and make sure webIDE/index.html is copied to the webIDE directory where Newspeak is served locally for https://localhost:8080/webIDE, or for https://newspeaklanguage.org/webIDE. I am serving from the git version of webIDE, so I do not have to copy anything. - Run . ./build.sh as normally. - Make sure the updated webIDE/sw.js is copied into the webIDE directory where Newspeak is served. I am serving from the git version of webIDE, so I do not have to copy anything.
PWA Client / browser
Motivation for change:
'Before this change': After a new Newspeak version deployment on https://newspeaklanguage.org/webIDE, the PWA client app on the user's device did not update even after multiple launches, unless a manual cache clean was performed. I had the same experience (the PWA client not updating) with the webIDE server running on localhost, and the PWA client created from it. In fact, even the in-browser running webIDE did not update after server deployment.
Having looked into how service workers function, it seems clear that the mechanism that causes the service worker update on the user's device (changing some bits) was never triggered. As a result, the service worker caches are never automatically updated, causing, among other things, the same (old) HopscotchWebIDE.vfuel to be used after server update.
Service worker lifecycle - summary
From https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Tutorials/CycleTracker/Service_workers: - Once the PWA is installed on the user's machine, THE ONLY WAY to inform the browser that there are updated files to be retrieved is to change the service worker (this file, sw.js) on the server.
Corollary: The only way for a PWA website to force an update of the service worker is to make a bit-change on the server's service worker (the sw.js).
Such enforced update of the service worker, causes the browser to call a one-time 'install' and 'activate' on the service worker, which the service worker can use to delete old caches and cache the new assets.
Changes in more detail: