Skip to content

perf: redirect codenames with a 301 and narrow the pagefind scan - #9

Merged
NotAFlightRisk merged 3 commits into
mainfrom
perf/codename-redirects
Sep 22, 2026
Merged

NotAFlightRisk merged 3 commits into
mainfrom
perf/codename-redirects

Conversation

@NotAFlightRisk

@NotAFlightRisk NotAFlightRisk commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Category

Perf

Overview

Every codename builds to a dist/devices/<codename>/index.html with a meta refresh inside it. That
works, but it answers 200 where a 301 belongs, and Pagefind printed a has no <html> element line
for all 711 of them, which was most of the build log.

The build now writes dist/_redirects too, off the same codenameRedirects map the config already
had, so Cloudflare answers those paths with a real 301. The HTML pages stay: the Docker image serves
the same dist through nginx, and nginx doesn't read _redirects.

Pagefind now scans {devices/*/*,roms/*}/index.html, which is exactly the set of pages carrying
data-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.

_redirects comes out at 711 rules, all 301, no duplicates. Checked the whole file rather than a
sample: every target resolves to a real page in dist, none of the 711 sources shadows one of the 49
brand 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 _redirects at 2000 static rules and 1000 characters a
line. 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 _headers from 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-body outside those two paths would drop out of the index
silently. tests/pagefind.test.js is the drift guard for it - it reads the glob straight out of
package.json and asserts it matches exactly the set of src/pages templates 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 -
codename is ^[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) and npm run build are all clean.

@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
android-rom-compat Ready Ready Preview Sep 22, 2026 7:41pm UTC

@NotAFlightRisk
NotAFlightRisk merged commit daacbd5 into main Sep 22, 2026
7 checks passed
@NotAFlightRisk
NotAFlightRisk deleted the perf/codename-redirects branch September 22, 2026 19:42

This branch was successfully deployed

1 active deployment
Preview — 70abfaa8 Deployed Sep 22, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant