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

Ignore index.html in service worker cache #522

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

MrTrustor
Copy link
Contributor

@MrTrustor MrTrustor commented Nov 1, 2024

Fixes #517

By default, index.html is cached by the service worker. This breaks the application if it's hosted behind an authentifying proxy which requires periodic revalidation of an auth token. Specifically, once the auth token expires:

  1. The index.html is still served from the service worker cache.
  2. Subsequent requests (e.g for JS resources) are redirected to the login page of the proxy.
  3. That login page is never displayed to the user as index.html has been successfully loaded.
  4. All requests but index.html fail, and the app displays a blank page.

This change fixes this behavior by preventing index.html from being cached by the service worker. With that change, once the auth token from the proxy expires:

  1. The request for index.html is not served from the service worker cache.
  2. Instead, a network request for index.html is made, and the user is properly redirected to the proxy login page.
  3. The user logs in, and index.html is served as normal.
  4. Subsequent requests (e.g for JS resources) succeed as now the auth token has been refreshed.

Fixes gramps-project#517

By default, index.html is cached by the service worker. This is
breaks the application if it's hosted behind an authentifying proxy
which requires periodic revalidation of an auth token.
Specifically, once the auth token expires
1. The index.html is still served from the service worker cache.
2. Subsequent requests (e.g for JS resources) are redirected to the
   login page of the proxy.
3. That login page is never displayed to the user as index.html has been
   successfully loaded.
4. All requests but index.html fail, and the app displays a blank page.

This change fixes this behavior by preventing index.html from being
cached by the service worker. With that change, once the auth token from
the proxy expires:
1. The request for index.html is not served from the service worker
   cache.
2. Instead, a network request for index.html is made, and the user is
   properly redirected to the proxy login page.
3. The user logs in, and index.html is served as normal.
4. Subsequent requests (e.g for JS resources) succeed as now the auth
   token has been refreshed.
@DavidMStraub
Copy link
Member

This shouldn't affect users that do not use an authentifying proxy, right?

On my setup, I've recently noticed I sometimes get a blank page on mobile when I open the app, I wonder whether it's related. This started a few months ago.

@MrTrustor
Copy link
Contributor Author

MrTrustor commented Nov 2, 2024

I don't think this would have any impact on users not using a proxy (the requests just happen without any redirection from a proxy since there is none) but it might be worth double checking.

If you want, you can use my docker image: ghcr.io/mrtrustor/gramps-web:devel

On Safari on iOS, I've always run into this blank page issue, which I'm assuming is the same I see on desktop. Though, if you're not using a proxy, I don't know what could be causing it.

@MrTrustor
Copy link
Contributor Author

@DavidMStraub Are you waiting for something from me on this PR?

@DavidMStraub
Copy link
Member

Nope 🙂

@DavidMStraub DavidMStraub merged commit a2b12fb into gramps-project:main Nov 10, 2024
1 check passed
@MrTrustor MrTrustor deleted the zero-trust-no-cache branch November 10, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants