CDN Latency Optimization: Reducing Time to First Byte

· James Thornton · 4 min read

Understanding CDN Latency Components

CDN latency is the sum of several components. To optimize it, you must understand and measure each one: For foundational context, read CDN Performance Metrics: What to Measure — FlyFish NWA.

Total TTFB = DNS + TCP + TLS + Edge Processing + (Origin Fetch on miss)

Cache HIT:  5-50ms = DNS(0-20ms) + TCP(5-15ms) + TLS(5-15ms) + Edge(1-5ms)
Cache MISS: 50-500ms = above + Origin(50-500ms)

DNS Optimization

DNS resolution adds 10-50ms for cold lookups:

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages
CDN Performance Dashboard — Core Web Vitals with CDN optimizationCDN Performance Dashboard — Core Web Vitals with CDN optimization CDN Performance Dashboard — Core Web Vitals Core Web Vitals with CDN LCP 1.8s Target: < 2.5s Good FID 45ms Target: < 100ms Good CLS 0.05 Target: < 0.1 Good TTFB 120ms Target: < 800ms Good
Figure 1: CDN Performance Dashboard — Core Web Vitals with CDN optimization

Connection Optimization

TCP + TLS handshake adds 20-100ms:

Edge Processing Optimization

Processing at the edge typically adds 1-5ms:

Request Timing — Latency breakdown across the CDN stackRequest Timing — Latency breakdown across the CDN stack CDN Request Flow — From Browser to Edge CDN Request Lifecycle Step 1 DNS Lookup Step 2 TCP Connect Step 3 TLS Handshake Step 4 Edge Server Step 5 Cache Check Step 6 Response Cache HIT → 5ms response Cache MISS → Fetch origin 0ms ~50ms (cache hit) ~200ms (cache miss)
Figure 2: Request Timing — Latency breakdown across the CDN stack

Cache Hit Ratio Impact

The single biggest latency factor is whether the response is a cache hit or miss. Improving cache hit ratio from 80% to 95% means 75% fewer users experience cache-miss latency.

Origin Latency Reduction

For cache misses, origin response time dominates:

Network Path Optimization

CDNs optimize network paths:

Preloading and Prefetching

Reduce perceived latency by fetching resources before they're needed:

See prefetch and preload strategies for implementation details.

External References

References & Standards: W3C Web Performance · Cloudflare documentation