Repository navigation
Stop the service worker re-flooding GitHub Pages on every reload - #197
Merged
Merged
Conversation
The production worker precached all 24,918 files in public/, most of them per-sprite atlas packer inputs the game never requests, in one atomic cache.addAll. GitHub Pages answered the burst with 503s, one failure discarded the install, and every reload started the whole download again. Precache only the bundle, shell and the public files the game requests (sprite manifest, atlas pages, UI icons), download them a few at a time, stop at the first failure and resume a retried install from what the build's cache already holds. Co-authored-by: Nori <contact@tilework.tech>
jiro-by-nori Bot
added a commit
that referenced
this pull request
Nov 5, 2026
Co-authored-by: Nori <contact@tilework.tech>
Contributor
Author
Live proof (deploy run https://github.com/tilework-tech/opencoaster/actions/runs/41946045318, main @5b47730c)
The after run used the same session-Chrome profile the old worker had left behind (an ordinary returning visitor). It kept storage, and the stale cache was removed automatically. Traces, scripts and README: https://github.com/tilework-tech/opencoaster/tree/7d261aef1cc3d0a4079195798260efe8723b35fb/pr-197 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
🤖 Generated with Nori
Root cause (verified on the live site): the production service worker precached all 24,918 files in
public/(≈150 MB; ~24.6k are per-sprite atlas-packer inputs the game never requests) in one atomiccache.addAllwithcache: 'reload'. Pages/Fastly answered the burst with503(server: Varnish,retry-after: 0, HTML body). One non-OK response rejectedaddAll, the worker was discarded with nothing cached, and every reload / reopened tab started the whole ~25k-request download again. In a clean profile on https://opencoaster.noriagentic.com/ the page never became controlled across first visit, 3 reloads, hard reload and tab reopen; each load issued 3k–24k worker requests, 21k of them aborted after the 503.tools/pwa/precache-urls.ts(used byvite.config.ts): precache only the bundle, shell and the public files the game requests (sprites/manifest.json,sprites/atlas/**,sprites/ui-icons/**; noCNAME). 24,918 → 278 URLs; worker script 1.68 MB → 12.6 KB. Offline play keeps every atlas page.src/pwa/service-worker.js: install downloads ≤6 files at a time, stops at the first failure, and resumes a retried install from what this build's cache already holds. Activation/fetch strategy unchanged; IndexedDB/localStorage never touched. No client reload logic (no reload loop risk).src/pwa/docs.md,docs/deploy/README.md,smoke/docs.md; corrected stale claims that UI icons are excluded from the atlas.Test Plan
vitest src/pwa tools/pwa tools/sprites/dist-icons.test.ts: resumable install, bounded concurrency +cache: 'reload', precache selection (each failed first on main).smoke/returning-visitor.spec.ts(production build under/opencoaster/, no COOP/COEP): returning visitor with an earlier build's cache, IndexedDB save and settings → worker controls with <1000 downloads, 3 reloads fetch only the navigation, old cache removed, save + settings intact, Load game lists the save. Fails on main's build (worker never controls within 60 s even on localhost).returning-visitor.spec.tsonly runs underpnpm smoke:subpath, which CI does not run; adding it toci.ymlneeds the workflow scope.Requested in Nori: https://demo.norisessions.com/chat/01a16c13-c814-7295-9955-b11ff875ed14
Share Nori with your team: https://www.npmjs.com/package/nori-skillsets