Skip to content
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

Frontend PWA requires two reloads after redeploy #1313

Closed
spwoodcock opened this issue Mar 1, 2024 · 6 comments
Closed

Frontend PWA requires two reloads after redeploy #1313

spwoodcock opened this issue Mar 1, 2024 · 6 comments
Assignees
Labels
bug Something isn't working frontend Priority: Must have QA ready Any issues that is fixed

Comments

@spwoodcock
Copy link
Member

spwoodcock commented Mar 1, 2024

Describe the bug

  • The PWA caches routes.
  • When redeployed, the old API calls are often cached and displayed.
  • On refresh sometimes a blank page is shown.
  • Yet another refresh finally shows the new deployed version of FMTM.

To Reproduce

  • Go to FMTM dev.
  • Redeploy.
  • Refresh the page.

Expected behavior

  • Caching is useful if users are in the field and have patchy internet.
  • We need a way to keep caching, but invalidate the cache if FMTM is deployed.
  • Is this possible?

Screenshots

image

Additional context

  • Note I could be wrong here and it's actually the Nginx proxy that is caching, not the PWA.
@spwoodcock spwoodcock added bug Something isn't working frontend labels Mar 1, 2024
@spwoodcock spwoodcock added this to the FMTM 2024.04 Release milestone Mar 1, 2024
@spwoodcock
Copy link
Member Author

Possibly related #1289

@spwoodcock
Copy link
Member Author

This is certainly due to the caching in the PWA:
https://stackoverflow.com/questions/57146097/service-worker-requires-double-refresh

Possible solutions:

@spwoodcock
Copy link
Member Author

@varun2948 @NSUWAL123 PWAs should work on either https secure context, or on localhost/127.0.01, so debugging locally should be possible 😄

Maybe it's a VitePWA thing in the config?

It's pretty easy to config a PWA without a plugin, we just need a manifest.json in the public directory.
Then we need to register a service worker.
Example code here: https://gitlab.com/mastweb/frontend/-/tree/main/src-pwa?ref_type=heads (the two .ts files)

@varun2948
Copy link
Collaborator

@spwoodcock i tried the pwa with vite-pwa plugin which kinda worked on the laptop version but in order to test it in mobile i might have to deploy right ?

@spwoodcock
Copy link
Member Author

You should be able to debug the server on your laptop from your mobile via the local network.

You just need the IP address of your laptop to connect to: local_ip:port.

Or of you are in an office, probably best to connect your phone to your laptop via USB, then go to:
chrome://inspect/#devices
And you can debug webpages from your phone.

Another option is ngrok - weren't you guys using this before too?

@spwoodcock
Copy link
Member Author

I will work on this to free up @NSUWAL123 to work on other tasks 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Priority: Must have QA ready Any issues that is fixed
Projects
Development

No branches or pull requests

4 participants