perf: redirect codenames with a 301 and narrow the pagefind scan - #9
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Category
Perf
Overview
Every codename builds to a
dist/devices/<codename>/index.htmlwith a meta refresh inside it. Thatworks, but it answers 200 where a 301 belongs, and Pagefind printed a
has no <html> elementlinefor all 711 of them, which was most of the build log.
The build now writes
dist/_redirectstoo, off the samecodenameRedirectsmap the config alreadyhad, so Cloudflare answers those paths with a real 301. The HTML pages stay: the Docker image serves
the same
distthrough nginx, and nginx doesn't read_redirects.Pagefind now scans
{devices/*/*,roms/*}/index.html, which is exactly the set of pages carryingdata-pagefind-body.Issue Number
Part of NotAFlightRisk/tasks#26, section 6.
Additional Info
No breaking changes, and the search index is untouched: Pagefind indexes 716 pages and 6413 words
before and after, byte for byte. The build log drops from 2248 lines to 1534 and the 711 warnings go
to zero.
_redirectscomes out at 711 rules, all 301, no duplicates. Checked the whole file rather than asample: every target resolves to a real page in
dist, none of the 711 sources shadows one of the 49brand pages or a device page, and all 711 agree with the meta-refresh target on the page they
replace.
Worth knowing for later: Cloudflare caps
_redirectsat 2000 static rules and 1000 characters aline. We're at 711 rules and a longest line of 81, so there's room, but the device list grows every
Monday and that first number is the one to watch. Cloudflare parses the file rather than serving it,
same as the
_headersfrom section 2.Codex flagged the one thing the before/after comparison can't see: that glob is an allowlist, so a
future page type carrying
data-pagefind-bodyoutside those two paths would drop out of the indexsilently.
tests/pagefind.test.jsis the drift guard for it - it reads the glob straight out ofpackage.jsonand asserts it matches exactly the set ofsrc/pagestemplates carrying the marker.Goes red both ways: drift the glob and it fails, add a searchable page type without widening it and
it names the pattern you're missing. It also asked about escaping, which the schema already answers -
codenameis^[a-z0-9]+([_-][a-z0-9]+)*$, so no rule can carry a space or a:.npm test(86, up from 85),npm run validate(728 files) andnpm run buildare all clean.