All Guides
TTFB 6 min read· Updated Apr 2026

How to Reduce TTFB (Time to First Byte) — Server Speed Guide

Cut your TTFB below 200ms with CDN configuration, caching strategies, server optimization, and edge computing. The foundation of all Web Vitals performance.

What is TTFB?

Time to First Byte (TTFB) is how long it takes from the browser's request to receiving the first byte of the response. While not a Core Web Vital itself, TTFB directly affects LCP and FCP. Target: under 200ms.


Every 100ms of TTFB improvement cascades into faster LCP.

Use a CDN for Edge Delivery

Serving your pages from a CDN edge location close to the user can cut TTFB by 100-500ms:


- Vercel — automatic edge deployment for Next.js

- Cloudflare Pages — global CDN with Workers

- AWS CloudFront — enterprise-grade CDN


For API routes, use edge runtimes:



javascript
// Next.js Edge API Route
export const runtime = 'edge'

export async function GET(request) {
  // Runs on Vercel Edge Network, ~10ms TTFB
  return Response.json({ data: 'fast' })
}

Implement Aggressive Caching

Use stale-while-revalidate for dynamic content:



javascript
// Next.js API route with ISR-style caching
export async function GET() {
  const data = await fetchFromDB()
  return Response.json(data, {
    headers: {
      'Cache-Control': 'public, s-maxage=60, stale-while-revalidate=600',
    },
  })
}


This serves cached content instantly and revalidates in the background.

Optimize Database Queries

Slow database queries are the #1 cause of high TTFB for dynamic pages:


1.Add database indexes — for frequently queried columns
2.Use connection pooling — (PgBouncer, Supabase built-in)
3.Avoid N+1 queries — use JOINs or batch fetching
4.Cache hot queries — with Redis or in-memory caches
5.Use read replicas — for geographically distributed users

Test these fixes on your site

Run a free audit to see your current TTFB score and get prioritized fix recommendations.

Run Free Audit

Related Guides

LCP8 min

How to Fix LCP (Largest Contentful Paint) — Complete Guide

General10 min

How to Improve Your Lighthouse Score from 50 to 90+