Repository navigation
fix(handbook): check for a new build on every navigation - #180
Merged
Merged
Conversation
The layout asked the server for its build version once, on mount. A check that ran while the GitHub Pages CDN still served the previous version.json (max-age=600) found nothing, and no later client-side navigation asked again, so the tab kept the cached build until its next full load. afterNavigate runs the same check after the initial load and after every navigation; the page still renders from the worker's cache first, and a differing version feeds the existing update-and-reload effect.
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.
Description
After #179 deployed, an open tab kept showing the previous build with
v2001.0.0in the version selector. The server was already correct.version.jsonreturned the new build id, the new worker precached 417 paths that all return 200, and/v2001.0.1/introductionreturned 200. The tab stayed stale because the layout asked for the build version once, on mount. GitHub Pages serves every file withmax-age=600, so a check in the ten minutes after a deploy can receive the oldversion.jsonfrom the CDN, and no client-side navigation asked again. This PR moves the check toafterNavigate, so every navigation re-checks in the background while the page still renders from the worker's cache.Changes Made
handbook/src/routes/+layout.sveltecallsupdated.check()fromafterNavigateinstead ofonMount.afterNavigateruns after the initial load and after every client-side navigation.version.jsonthrough withcache: 'no-store'.updated.currentturns true it callsregistration.update(), polls until the new worker's cache is the only one, and reloads.Performance Impact
Each client-side navigation makes one extra request for
_app/version.json, which is 27 bytes on the live site. Nothing changes for the core library.Test Coverage
npm run checkinhandbook/: svelte-check reported 374 files, 0 errors, 0 warnings.BASE_PATH=/beacon npm run buildinhandbook/completed.version.json, without a manual reload.Related Issues
This follows #179. The maintainer reported the stale tab on 2026-10-19.
Checklist