Skip to content

fix: cache static assets and load result rows only when needed - #20

Merged
ChloeQuijano merged 1 commit into
mainfrom
perf/static-cache-and-lazy-rows
Dec 2, 2026
Merged

ChloeQuijano merged 1 commit into
mainfrom
perf/static-cache-and-lazy-rows

Conversation

@ChloeQuijano

Copy link
Copy Markdown
Collaborator

Summary

  • Next's hashed files under /_next/static/ (scripts, CSS, fonts) were served with cache-control: max-age=0, must-revalidate, so every visit re-checked all of them. They now get public, max-age=31536000, immutable; a changed file always gets a new hashed URL.
  • After hydration the homepage downloaded the default view's whole summary (188 KB compressed, about 1.9 MB raw) only to get its per-target rows. Rows now load only when the failure explorer nears the viewport or a results row is expanded, so a visitor who stays near the top fetches no data after load.
  • ws is bumped to 8.23.1 for GHSA-37g9-w4hg-h9qr (high severity), which npm audit now fails on.

Changes

  • netlify.toml: one [[headers]] rule for /_next/static/*.
  • website/scripts/build-public-data.ts: writes each view without rows to /api/views/<month>-<region>.json and its rows to /api/rows/<month>-<region>.json. The old /api/summaries/ files are no longer built, so a page loaded before this deploy gets a 404 and shows its load error instead of crashing on the new format.
  • website/src/components/Dashboard.tsx: the default view uses only the data in the HTML; another view fetches its summary (about 22 KB compressed instead of 188 KB); rows are fetched after the first request and then for each view shown.
  • Sections.tsx (FailureExplorer) requests rows when within 800 px of the viewport; ResultsTable.tsx requests them when a row is expanded. Both show an error line if the rows fail to load.
  • package-lock.json: ws 8.22.2 → 8.23.1, within the ranges puppeteer-core and the provider SDKs already allow.
  • Unchanged: the HTML, every figure, results.json, table.csv, and Copy page (it uses precomputed counts, not rows).

Benchmark impact

  • No methodology, scoring, target, task, pricing, schema, or published-result change
  • User-visible benchmark change documented in CHANGELOG.md
  • No paid benchmark was run, or live-run approval and scope are documented
  • No credentials, account identifiers, recordings, or raw private provider responses are included

Verification

  • npm run corpus:check
  • npm run lint
  • npm run typecheck
  • npm test (518 passed)
  • npm run website:build

Also ran npm audit --audit-level=high --omit=dev (clean), gitleaks and trufflehog (no findings), and checked the static export in a browser: staying at the top makes no /api/ request; scrolling to the failure explorer fetches only the rows file and shows the same rows and counts; expanding a results row shows a loading line, then the detail rows; a ?version=2026-09&region=us-east link fetches only its 21 KB view file; no console errors. The cache header can be confirmed on this PR's deploy preview.

🤖 Generated with Claude Code

Hashed files under /_next/static/ get a one-year immutable cache instead
of max-age=0. The homepage no longer downloads the default view's full
summary after load just for its per-target rows: rows now live in
/api/rows/<month>-<region>.json and load when the failure explorer nears
the viewport or a results row is expanded, and other views fetch a
summary without rows from /api/views/. Also bumps ws to 8.23.1 for
GHSA-37g9-w4hg-h9qr.
@netlify

netlify Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for browser-benchmark ready!

Name Link
🔨 Latest commit a671cf4
🔍 Latest deploy log https://app.netlify.com/projects/browser-benchmark/deploys/6b102a6729fd1ec400274322
😎 Deploy Preview https://deploy-preview-20--browser-benchmark.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@ChloeQuijano
ChloeQuijano marked this pull request as ready for review December 2, 2026 15:15
@Xrazik1

Xrazik1 commented Dec 2, 2026

Copy link
Copy Markdown

Tested at a671cf4a, against main at d33a0dbc. No findings.

Ran locally.

What I ran

  • Repo checks: on Node 26.13.0 in a Linux container, npm ci, then lint, typecheck, the test suite (518 of 518 pass) and the static site build, on both main and this head. All pass on both.
  • The data split: for every month and region, the new /api/views/… file plus its /api/rows/… file hold exactly the data that the single /api/summaries/… file holds on main. Nothing is lost or changed.
  • The built site in headless Chromium: I served both static builds and loaded them at 1280×900.
    • On load: main fetches the full summary for the default view straight away. This head fetches nothing, because the default view is in the page, and the failure explorer shows "Loading rows…".
    • Scrolling: scrolling to about 2,500 px above the failure explorer still fetches nothing. Scrolling to within about 600 px of it fetches /api/rows/2026-10-us-west.json once. The explorer then lists 211 rows, the same count as main for that view.
    • Expanding a results-table row on a fresh load also fetches the rows, and fills the failure explorer.
    • Switching region to eu-west fetches that view and its rows. Switching back to us-west fetches nothing again, because both are cached.
    • Opening /?region=eu-west directly fetches only the view. The rows wait until they are needed.
    • No console errors or page errors in any of these.
  • The header rule: Cache-Control: public, max-age=31536000, immutable applies only to /_next/static/*. Those files have content hashes in their names, and the /api/ data files keep the default caching.
  • The lockfile: the only change is ws 8.22.2 to 8.23.1. The integrity hash matches the one the npm registry publishes for 8.23.1.
  • CI: every check passes at this head.

Not covered

  • The "Couldn't load the rows" messages, which need a failed request. I did not simulate a network failure.
  • Real-network timings. I checked which requests are made and when, not how much faster the page loads.

Security

  • 2 of 16 attack classes apply:
    • Web client surfaces: the page builds fetch URLs from the month and region in the query string. The region is only used if it is in that month's list of regions, otherwise it falls back to the default. The fetched JSON is rendered through React, so it is escaped.
    • Supply chain: the ws update, checked against the registry as above.
  • /security-review on this PR found nothing.

@Xrazik1 Xrazik1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No findings at a671cf4a; see the test report.

@ChloeQuijano
ChloeQuijano merged commit 69870ef into main Dec 2, 2026
9 checks passed
@ChloeQuijano
ChloeQuijano deleted the perf/static-cache-and-lazy-rows branch December 2, 2026 15:57
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.

2 participants