Service worker cache messing with authentication
See original GitHub issueHello there ! Thanks for the amazing work !
I am trying to make OHIF work behind a reverse-proxy which handles authentication. When unauthenticated, it simply redirects to the login page.
The problem is, whenever the status changes (when logging-in or logging-out), the OHIF page is broken, because it caches everything : the browser’s request to /
gets answered by the ServiceWorker, which prevents my reverse-proxy redirection.
Is there a way to disable the caching for the main page?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Service Worker mishandling user login on App Engine
The problem is, despite the fact that I don't try to cache the root address, the service worker will try to return a...
Read more >Using Service Workers - Web APIs | MDN
A service worker functions like a proxy server, allowing you to modify requests and responses replacing them with items from its own cache....
Read more >Session management with service workers - Firebase - Google
Firebase Auth provides the ability to use service workers to detect and pass Firebase ID tokens for session management. This provides the following...
Read more >Service worker does not support basic authentication
The auth challenge information isn't stored on the FetchAPIResponse and thus doesn't make it into ServiceWorkerMainResourceLoader where we ...
Read more >Strategies for Service Worker Caching for Progressive Web ...
Service Worker caching enables offline first apps. In case its a broken deployment you can't quickly apply a patch because service-worker.js ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dannyrb thanks for your help, but I managed to work-around my problem by not putting OHIF itself, but only the backend it connects to, behind the authenticating reverse-proxy, then using the
httpErrorHandler
option ofapp-config.js
to redirect to the login page upon 401.I must however point out that having
index.html
cached this aggressively seems to me to be contrary to usual best-practices… For example, if the server updates its version of OHIF Viewer, a client can basically never get the new version without doing a manual Hard reload. From what I have seen most often in deployments, the main page (which is usually pretty light anyway in modern SPAs) is not cached at all, and calls resources (JS and CSS) with unique names (random, or even hashes), so they are cached as much as possible, but are updated as soon as the main page requests a new version.Thanks, @dannyrb I’ll keep an eye open for when this happens so I can document how to reproduce and file a report. Basically I was just using the
http-server
package on a static site and it would not load unless I usedcommand-shift-R
.