I am using a service worker to cache the static resources for my website. The cache name is key’ed by the Last-Modified header so that I can do a rolling deployment. The user will only ever be shown a full set of static resource from one release. After the release is complete, the service worker cache is updated.
The fetch event looks like this:
event.respondWith(caches.match(event.request).then(r => r || fetch(event.request)))
I’ve hit an issue where I’m getting a 401 when visiting the site root /. It’s a cache miss (which is a problem in itself but I can look at that separately) and is calling fetch().
The site is protected by OIDC where authentication is done via SPNEGO (i.e. there is no login screen). The OIDC access token lifespan has a maximum of 12 hours (including any refreshes).
I assume the fetch is unable to follow the redirects to re-fetch an access token (for the OIDC protocol), but I can’t figure out what I need to do to solve it.
Sidebar: Had it been a cache hit, I would have had an invalid token anyways…I feel like OIDC with service worker should be a solved pattern but I couldn’t find anything via Google.