ci(pages): cache-bust openapi.json with commit SHA - #22
Merged
Merged
Conversation
After PR #21 deployed, the Pages site kept serving the prior endpoint summaries because GitHub Pages sets a long-lived Cache-Control on static assets and Scalar memoises the fetched spec client-side. Result: correct spec on the wire, stale spec in every previously-opened tab until a hard reload. Append `?v=__CACHE_BUST__` to the `data-url` in docs/index.html and substitute the literal at deploy time with `${GITHUB_SHA}` via a one- line sed step in pages.yml. Each release rotates the query string, so browsers (and Scalar's localStorage cache) fetch the new spec. Local dev keeps working — `python -m http.server -d docs` happily serves `openapi.json` regardless of the query string. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Owner
Author
|
@claude could you review? |
|
Claude finished @jstjoe's task in 1m 0s —— View job Review
Verdict: LGTM — clean, minimal fix. A few observations below, none blocking.
|
`docs/index.html` is the only entry point today, but the substitution
should cover any future HTML page that drops in the `__CACHE_BUST__`
token. Switch from a path-pinned `sed -i ... docs/index.html` to
`find docs -name '*.html' -exec sed ... {} +` so the next page added
under docs/ gets the bust for free.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
After #21 deployed, the Pages site kept serving the old endpoint summaries because GitHub Pages sets a long-lived
Cache-Controlon static assets and Scalar memoises the fetched spec client-side. Spec on the wire was correct; spec in every previously-opened tab was stale until a hard reload.Fix: append
?v=__CACHE_BUST__to thedata-urlin docs/index.html; substitute the literal at deploy time with${GITHUB_SHA}via a one-linesedstep in .github/workflows/pages.yml. Each release rotates the query string, so browsers (and Scalar's localStorage cache) fetch the new spec.Local dev keeps working —
python -m http.server -d docshappily servesopenapi.jsonregardless of the query string.Test plan
docs/index.htmlviapython -m http.server -d docs; Scalar still loads the spec (literal token doesn't break the static server).pages.ymlruns, deployedindex.htmlhas?v=<sha>, hard reload no longer required.Cmd+Shift+R.🤖 Generated with Claude Code