question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Service worker cache messing with authentication

See original GitHub issue

Hello 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
arantes555commented, Apr 28, 2020

@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 of app-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.

0reactions
piepercommented, Apr 28, 2020

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 used command-shift-R.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found