SW with gh-pages - Parent SW

https://huangxuan.me/sw-with-gh-301 https://huangxuan.me/sw-with-gh-301/ https://huangxuan.me/sw-with-gh-301?query The Service Worker Codes (located in huxpro.github.io/blob/master/sw.js)

In this DEMO. The SW is registered under huangxuan.me

Visit /sw-with-gh-301 Without SW:

  1. Github Pages redirect /sw-with-gh-301 to /sw-with-gh-301/
  2. Done

Visit /sw-with-gh-301 With SW:

  1. SW intercepts https://huangxuan.me/sw-with-gh-301
  2. Replace with https://huangxuan.me/sw-with-gh-301?${randomQuery} (for caching-bust & revalidate)
  3. Github Pages wont redirect it to https://huangxuan.me/sw-with-gh-301/${randomQuery}, it response with 404 instead
  4. Response not ok, can not cache and nothing to display...

Comparision

Potential Solutions

  1. Fixing all navigation url not ended with '/'. Though Request.type & Request.destination hasnt implementated yet, Request.mode and its polyfillas googlechrome.github.io/samples/service-worker/custom-offline-page/ showed can be a workaround
  2. Is there any methods we can prevent parent SW from installing? Kinda overriding? It seems SW scope can not help in this scenario
  3. Waiting for browsers support Fetch API cache: no-store so web developers can bypass HTTP Caching provided by gh-pages or any CDN when needed and without any hacks. Should I concluded that Github-Pages' environment is super unfriendly with SW...sigh