Anurag’s Read

From latency to instant: Modernizing GitHub Issues navigation performance.

A strong client-side caching story with a clear metric, traffic mix, explicit staleness trade-off and before/after percentiles. A product engineer can copy the approach for any read-heavy page.
Score
8.4
Verdict
Worth reading
Blog and date
GitHub,
Original length and level
15 min, intermediate
Topics
frontend performance, caching, service worker, web
Read the original

Context

GitHub measures page speed with HPC, a metric close to Largest Contentful Paint. It buckets loads as instant under 200 ms, fast under 1 second and slow above that. Most issue views were hard navigations, which are full page loads.

Journeys that cross the Rails and React boundary force those hard loads.

Architecture

A React soft navigation first reads an in-memory cache. If that misses, it reads IndexedDB, then revalidates in the background and reconciles the store. A preheating worker fills the cache from issue links on lists, dashboards and projects.

A service worker intercepts Turbo and hard navigations. On a cache hit it adds a header so the server returns a thin HTML shell. React then renders from the cached payload.

On any miss the normal server-side render runs.

Mechanisms

M1

IndexedDB stale-while-revalidate

Render from local data first. Fetch fresh data in the background and update the in-memory store. Revisit analysis estimated a 30% hit ratio, which made the idea worth building. The observed ratio was about 33%, and server and cache differed in about 4.7% of cases.

M2

Preheating

It walks high-intent issue references and fills the cache. It fetches only when no usable entry exists. It runs in low-priority workers with strict rate limits and circuit breakers. User-triggered work always goes first.

M3

In-memory layer

It sits in front of IndexedDB. Hot payloads read synchronously, which removes an async step from the critical path. Together with preheating, hit ratio reached about 96%.

M4

Service worker

It trades server render time for client work. Hard navigations then depend on JavaScript download and run time. Route-level and component-level code splitting, plus hover prefetch, reduce that cost.

Design decisions

No.ChoseInstead ofWhy
D1Use IndexedDB with an in-memory layerMemory-only store or localStorageMemory loses data on reload and localStorage has a small quota.
D2Preheat only high-intent linksEager prefetch of every likely issuePrefetching everything multiplies requests on pages with many links and wastes compute.
D3Ship cache and service worker nowWait for the full React migrationWaiting would delay the gains.

Key numbers

  • Hard navigations: 57.6% of traffic; React soft navigations: 37.5%.
  • Instant React navigations: 4% to about 22%.
  • Instant issue views: about 30% overall, up to 70% of React navigations.
  • Cache hit ratio: about 96% after preheating.
  • P10: 600 ms to 70 ms; P50: 1,200 ms to 700 ms.
  • P90: 2,400 ms to 2,100 ms.

Failures and limits

  • Cached data can be stale, and the team accepts about 4.7% divergence.
  • Cold starts still use server-side render.
  • The P90 tail is still high.
  • Preheating uses some background capacity.
  • The Rails and React boundary still forces full loads.

Lessons you can use

  • Track the share of fast loads across all users, not only p99.
  • Separate cache population from freshness checks to control cost.
  • Estimate the hit ratio from real revisit data before building a cache.
  • Make every optimization fall back to the normal path.

Glossary

HPCHighest Priority Content, the time until the main element of the page first renders.
Stale-while-revalidateShow cached data at once, then refresh it in the background.
TurboA library that swaps page content without a full reload.
Service workerA browser script that can intercept page requests.