GitBook's 300ms Cache Invalidation for 30k Sites

GitBook uses Vercel's tag-based cache invalidation on merge events to deliver sub-300ms updates across 30k multi-tenant docs sites, serving 120M pageviews/month with 41% from AI crawlers.

Tag-Based Invalidation Delivers Sub-Second Updates in Multi-Tenant Systems

Cache individual data-fetching functions with Vercel's use cache directive to deduplicate expensive API calls across requests, making cache behavior explicit in Next.js code rather than hidden configs. For 30k independently updated sites, avoid broad purges by tagging cached data by content unit (e.g., site or page ID). Trigger revalidation only on affected tags via merge events from GitBook app, GitHub, or GitLab—processing 40k invalidations daily in under 300ms globally. This ensures one team's typo fix doesn't evict caches for 29,999 other sites, keeping unrelated content fresh without rebuilds. Result: merge immediately means live, eliminating post-merge lag that frustrated users like a customer whose docs trailed a feature launch.

Trade-off: Building custom caching was considered but rejected; Vercel's edge handles multi-tenant scale without it, as Steven Hall (GitBook Head of Engineering) notes: "Vercel was really the only option that made sense."

High Cache Hits Handle Unpredictable AI Traffic Spikes

With 41% of 120M monthly pageviews from AI crawlers (5x YoY growth in 2025), traffic patterns shift—crawlers sweep every page across hundreds of sites per session, hitting cold caches humans rarely touch. Target near-100% cache hits for sub-second latency regardless of traffic source, as fast docs are table stakes for engineering teams and AI apps using GitBook as truth for SDKs/internal tools. Infrastructure must ensure immediate consistency post-merge while keeping costs predictable at volume; the tag system scales here by minimizing revalidation blast radius.

Scaling Caching for Adaptive Docs and 10x Volume

Current setup supports 30k sites from Nvidia, Zoom, n8n; next phase tackles adaptive content (personalized by reader), complicating multi-tenant tags, plus rising engineer-driven merges and LLM crawls. Maintain <300ms latency by prioritizing predictable edge caching over custom layers—volume up means more changes, but targeted invalidation keeps costs linear. GitBook's Next.js frontend is open-source, enabling similar patterns for your docs at scale.

Summarized by x-ai/grok-4.1-fast via openrouter

4706 input / 1445 output tokens in 13410ms

© 2026 Edge