-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to trigger refresh of PWA #64
Comments
go-app Has an AutoUpdate feature And a version It looks like AutoUpdate is passed into the app.js template. In app.js the app registers a refresh |
It looks like the autoUpdateInterval is currently being set to 0 which disables autoUpdates
|
The actual app.js template is here |
So it looks like one issue is that if we rebuild the WASM application but don't restart the static server the GOAPP version doesn't change. You can verify this by looking at the GOAPP_VERSION
Intuitively this makes sense as the logic that sets the GOAPP_VERSION in the server isn't being retriggered just because we rebuilt the frontend. |
Page describing the app lifecycle |
It looks like the version gets set on the handler |
We register the handler here foyle/app/pkg/server/server.go Line 250 in ac42d0a
So we could potentially change the Version on the handler each time it is fetched. Per the https://go-app.dev/lifecycle to trigger an update we need to do two things
|
It looks like updating the Version on the handler won't work because the rendered app.js are cached inside the handler. Here's my failed attempt So we probably need to recreate the handler in its entirety. |
Rather than just reloading the client application. It might make more sense just to create a simple program that watches for file changes and automatically
|
In #96 I added a status bar which displays the goapp version. This makes it easy to see when the app has been reloaded.
I think the first refresh is necessary to trigger the service worker to check for changes to the app and download them. Once the changes are downloaded the second refresh is needed to actually load them. I think we could potentially eliminate the need for two refreshes by using the autoUpdate mechanism or there might be a notification method to automatically trigger the client to check for an update. Notably though we don't have to clear application site data. That was annoying because it meant we lost all of our local settings which were saved in local storage. Now that we have a recipe we can close this issue. |
VSCode For Web Is A Progressive Web App
Refreshing the page doesn't seem to redownload assets.
This can lead to version skew because the backend might be newer than the app.
You can use chrome developer console -> Application Page and clear site data. It seems like you can potentially select what to clear so you don't clear VSCode settings.
Still this is far from a good solution. Ideall the app should automatically check if its out of date and trigger a refresh
The text was updated successfully, but these errors were encountered: