SW with gh-pages - Own SW

https://huangxuan.me/sw-with-gh-301-own-sw https://huangxuan.me/sw-with-gh-301-own-sw/ https://huangxuan.me/sw-with-gh-301-own-sw?query The Service Worker Codes (located at sw-with-gh-301-own-sw/blob/master/sw.js

In this DEMO. The SW is registered under huangxuan.me/sw-with-gh-301-own-sw/

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

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

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

  1. There is no SW avaliable under /sw-with-gh-301-own-sw
  2. Github Pages redirect /sw-with-gh-301-own-sw to /sw-with-gh-301-own-sw/
  3. Register SW in the first time, and SW intercept /sw-with-gh-301-own-sw in revisit
  4. SW replace it with https://huangxuan.me/sw-with-gh-301/?${randomQuery} (for caching-bust & revalidate)
  5. Done

Visit /sw-with-gh-301-own-sw With SW after visiting https://huangxuan.me ("The Parent")

  1. The parent SW registerd
  2. Though own SW is not avaliable under /sw-with-gh-301-own-sw, but the parent SW do....
  3. Parent SW intercepts https://huangxuan.me/sw-with-gh-301-own-sw
  4. Replace with https://huangxuan.me/sw-with-gh-301-own-sw?${randomQuery} (for caching-bust & revalidate)
  5. Github Pages wont redirect it to https://huangxuan.me/sw-with-gh-301-own-sw/${randomQuery}, it response with 404 instead
  6. Response not ok, can not cache and nothing to display...
  7. Future Revisit performs exactly same with https://huangxuan.me/sw-with-gh-301/

Comparision