Repository navigation
perf(web): hold pages until their data can next change - #127
Merged
Merged
Conversation
The edge page cache kept a second copy of every page per sidebar state. A head script now reads the cookie before first paint and on each client-side navigation, so the server renders one cookie-free page.
Workers Free stops a request at 10 ms of CPU and an uncached page render takes 15-100 ms, so only edge-cache hits stay under it. On 2026-11-17 a crawler walking distinct URLs made nearly every request a fresh render and about 1,100 hit the limit. Pages and the API answers behind them now hold 10 minutes inside a write window and otherwise until the next window or 00:00 UTC, keyed by build so a deploy starts fresh. Unknown ids answer 404 and are kept; a render that saw an API outage answers 503 or shows its fallback and is never kept, where a "Couldn't load" page used to stick for an hour.
Deploying f1-prediction-platform-web with
|
| Latest commit: |
b6183ab
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c8de82fd.f1-prediction-platform-web.pages.dev |
| Branch Preview URL: | https://fix-page-cpu-budget.f1-prediction-platform-web.pages.dev |
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
Workers Free stops a request at 10 ms of CPU. A page rendered from scratch takes 15–100 ms, so only edge-cache hits stay under it. On 2026-11-17 Meta's
meta-webindexerwalked ~11k distinct URLs and about 1,100 renders were cut off. That crawler is now blocked by a zone WAF rule (already live, documented indocs/deployment.md); this PR makes the cache hold far more of what's left.sidebarcookie before first paint and on each client-side navigation, so one copy serves everyone.apiCache.ts) are held as long as pages and keyed by build too, so a deploy starts fresh.api.tsreports failures throughapiFailure.ts, so browser islands never importnode:async_hooks.Evidence
exceededResources. Locally, uncached renders take 15–100 ms of CPU, against 2–9 ms for a cache hit.After (production build under local workerd, real API):
/drivers/999991→ 404, and the repeat comes from cache in 9 ms./driverswith a collapsed-sidebar cookie is served the expanded visitor's copy in 9 ms./drivers→ 503 on every request and the home page shows its fallback. 0 cache entries written, against 18 in the healthy run (all keyed__build=).bun test/vitest: 376 passed. Playwright smoke (sidebar, mobile, drivers, races): 26 passed, including "a collapsed sidebar stays collapsed across navigation and reloads".Merge Danger
Door: two-way
Revert and redeploy. The build id in every key means old copies are never served by the next build.
Blast Radius: freshness
A manual Neon write outside a write window now shows on the site only after a redeploy or at 00:00 UTC (was ≤ 1 h). Scheduled ETL writes are unaffected.