perf: cache the versioned assets for a year - #11
Merged
Merged
Conversation
Every asset carried Cloudflare's default of max-age=0, must-revalidate, so a returning visitor revalidated style.css and generator.js on every load, two round trips before first paint that the ?v= scheme already makes unnecessary: the number moves whenever the file does, and CI fails the build when it does not. The six files that carry a ?v= now get a year-long immutable cache. Pages keep the default, since their names never change, and so does the vendored GIF encoder, which has no ?v=. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
flield | ef8cc4b | Commit Preview URL Branch Preview URL |
Sep 13 2026, 10:37 PM |
Owner
Author
|
Verified on this branch's Workers preview with
|
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.
What does this change?
Adds
Cache-Control: public, max-age=31536000, immutablein_headersfor the six files that are requested with a?v=query:style.css,generator.js,guide.css, and the three screenshot files.Today every asset carries Cloudflare's default
max-age=0, must-revalidate, so a returning visitor revalidates the stylesheet and the generator on every load. That's two round trips before first paint that the?v=scheme already makes unnecessary: the number moves whenever the file changes, and CI fails the build when it doesn't (both directions, on every page that requests the file).Left on the default on purpose:
vendor/gif/*, which carries no?v=. A swapped file under the same name would sit stale for a year.Related issue
None. Noticed while looking at the LCP report.
How was this tested?
curl -Iagainst this branch's Workers preview, before merge, to confirm the versioned assets carry the new header and the pages do not (result in the PR comments below once the preview is up).python3 .github/scripts/checks.py mainpasses.Checklist
generator.jsstill has no dependency on the UI, if touched (not touched)🤖 Generated with Claude Code