What You Will Learn
- Exactly what TTFB measures and why it sets the ceiling for LCP
- The three server-side contributors to TTFB: DNS, connection, and processing time
- How CDNs reduce TTFB by serving cached responses from edge locations
- Server-side caching strategies — page caching, object caching, reverse proxy
- How HTTP 103 Early Hints allows critical resources to load during server processing
- Database query optimisation as a hidden TTFB lever
- How to measure TTFB using Chrome DevTools, WebPageTest, and Search Console
What is TTFB
Time to First Byte measures the time between a browser sending an HTTP request for a page and receiving the first byte of the HTML response. It encompasses three sequential phases: DNS lookup time (resolving the domain to an IP address), connection time (TCP handshake plus TLS negotiation for HTTPS), and server processing time (generating and beginning to send the HTML response).
Google recommends a TTFB under 800ms for a good LCP score. TTFB itself is not a Core Web Vital and does not directly affect page ranking — but because it determines when the browser can begin discovering and loading all other page resources, high TTFB raises LCP proportionally.
Good TTFB
Google's recommended maximum for good LCP
Needs improvement
Will likely cause LCP to miss the 2.5s threshold
Poor TTFB
Server is a significant bottleneck — action required
Why TTFB Directly Sets the Floor for LCP
LCP cannot be faster than TTFB. The browser cannot begin downloading any resource — images, CSS, fonts — until it has parsed the HTML. It cannot parse the HTML until the first byte arrives. For a page with a 2-second TTFB, LCP cannot possibly be under 2 seconds regardless of how well-optimised the images and CSS are.
Google's analysis of HTTP Archive field data consistently shows TTFB as the largest single contributor to LCP time on pages that fail the Core Web Vitals assessment — accounting for 40–60% of total LCP time on slow pages. Fixing TTFB first provides the highest leverage before optimising other LCP sub-parts.
Reducing an image from 300KB to 100KB saves download time, but that saving is capped by available bandwidth. Reducing TTFB from 2s to 200ms saves 1.8 seconds unconditionally — on every device, at every connection speed. Server-side optimisations have disproportionate impact.
Common Causes of High TTFB
- No CDN — single origin server. A user in Mumbai requesting a page from a server in London adds 140ms of round-trip latency before a single byte is received. Multiply by the TCP handshake (3 round trips) and TLS negotiation (1–2 round trips) and the connection overhead alone exceeds 600ms.
- Uncached dynamic pages. CMS platforms generating pages by querying a database on every request can take 500ms–3s of server processing time per request under load.
- Slow database queries. Missing indexes, N+1 query patterns, and unoptimised joins on large tables directly extend server processing time.
- Inadequate server resources. CPU throttling on shared hosting under load, insufficient RAM causing swap usage, and connection pool exhaustion all increase server processing time.
- Synchronous external API calls. Server-side code that waits for third-party API responses (payment processors, personalisation engines, recommendation systems) before rendering the page adds the API's latency to TTFB.
- Uncompressed responses. Not enabling Brotli or gzip compression increases response size and transfer time — affecting Time to Last Byte even if TTFB itself is low.
Fix 1 — Deploy a CDN
A Content Delivery Network is the highest single-impact TTFB fix for most sites. CDNs cache your pages and assets at edge servers in dozens to hundreds of geographic locations. When a cached page exists at the nearest edge, a user's request is served from a server typically under 20ms away rather than a distant origin server.
CDN caching of HTML is not automatic — it depends on your Cache-Control response headers. For pages that do not change with every request (most blog posts, product pages, category pages), set appropriate cache headers:
# For pages that can be cached at the CDN edge
Cache-Control: public, max-age=3600, stale-while-revalidate=86400
# For user-specific pages (shopping cart, account pages)
Cache-Control: private, no-store
The stale-while-revalidate directive serves the cached version immediately while asynchronously revalidating it in the background — ensuring users always get a fast response even when the cache is being refreshed.
Images, CSS, and JavaScript files that change infrequently should be cached at the CDN with long TTLs. Use content-based cache-busting (fingerprinting filenames with a hash of the content) to allow aggressive long-term caching while ensuring updates are picked up immediately:
# Static assets with content hash in filename
# e.g. /styles/main.a3f4b2c1.css
Cache-Control: public, max-age=31536000, immutable
Fix 2 — Server-Side Caching
When a CDN cache miss occurs — for user-specific pages or cache-busted requests — the origin server must generate the response. Server-side caching keeps generated HTML in memory so repeat requests do not re-execute database queries and template rendering.
Full-page caching stores the complete rendered HTML of a page in memory (Redis, Memcached) or on disk. The first request generates the page normally; subsequent requests serve the cached HTML directly, bypassing the database entirely. TTFB drops from 300–2000ms to 5–50ms for cached pages.
Implementations by platform: W3 Total Cache or WP Super Cache for WordPress; Laravel's response caching middleware; Nginx fastcgi_cache for PHP applications; Varnish Cache as a reverse proxy in front of any web server.
Object caching stores the result of individual database queries in memory. Rather than re-querying the database on every request, the application checks the cache first. Redis and Memcached are standard object cache backends. Effective for shared data accessed across many pages (site navigation, popular products, user roles) without caching entire page output.
Fix 3 — Server and Database Optimisation
For pages that cannot be fully cached (personalised content, live data), server and database optimisation directly reduces the processing component of TTFB.
- Database indexes. Ensure columns used in WHERE, JOIN, and ORDER BY clauses are indexed. A single missing index on a high-traffic query can increase query time from milliseconds to seconds. Use
EXPLAINin MySQL/PostgreSQL to identify full table scans. - Eliminate N+1 queries. The N+1 pattern (one query to fetch a list, then one query per item to fetch related data) is one of the most common database performance problems. Use eager loading (JOINs or ORM includes) to fetch all required data in a single query.
- Connection pooling. Establishing a new database connection for every HTTP request adds 20–100ms overhead. Use connection pooling (PgBouncer for PostgreSQL, MySQL connection pool) to reuse existing connections.
- Move to faster hosting. Shared hosting CPU throttling produces high and unpredictable TTFB under even moderate load. Moving to a VPS, managed cloud instance, or dedicated server with adequate CPU and RAM is often necessary for consistently good TTFB.
Fix 4 — HTTP 103 Early Hints
HTTP 103 Early Hints is a response status code that allows the server to send Link: rel=preload headers to the browser before the full 200 response is ready. While the server is still processing the page request — querying the database, rendering templates — the browser can begin fetching critical resources (the LCP image, the main CSS file, key fonts) in parallel.
The practical effect: resources that previously had to wait for TTFB before downloading can start downloading during server processing time, overlapping Phase 1 (TTFB) and Phase 2 (resource load delay) of LCP simultaneously.
HTTP/1.1 103 Early Hints
Link: </styles/main.css>; rel=preload; as=style
Link: </images/hero.webp>; rel=preload; as=image; fetchpriority=high
HTTP/1.1 200 OK
Content-Type: text/html
...actual HTML response...
Chrome has supported Early Hints since version 103. Server-side support: Cloudflare Workers and Pages support Early Hints natively; Apache and Nginx require explicit configuration; most modern CDNs (Fastly, Akamai) support them at the edge.
Measuring TTFB
| Tool | Data Type | What to Look At |
|---|---|---|
| Chrome DevTools — Network | Lab | Click any HTML request, "Timing" tab — TTFB is "Waiting (TTFB)" row. Hover over the request bar for a tooltip breakdown. |
| Google Search Console — Core Web Vitals | Field (CrUX) | Not a direct TTFB report, but poor LCP with a fast connection suggests high TTFB. Use Crawl Stats for server response time trends. |
| PageSpeed Insights | Field + Lab | Lab "Server Response Times" diagnostic shows TTFB. Field LCP data reflects real user TTFB impact. |
| WebPageTest | Lab | Waterfall shows TTFB per request. "Time to First Byte" column in results. Test from multiple geographic locations to isolate CDN gaps. |
Test from multiple locations
TTFB varies significantly by geographic distance to the origin server. WebPageTest allows testing from specific cities globally — a site with TTFB of 80ms from London may show 600ms from Singapore if no Asia-Pacific CDN edge is configured. Always test from locations representative of your actual user base.
Authentic Sources
Official TTFB definition, good/poor thresholds, and how TTFB affects LCP.
Practical guidance on CDN, server caching, 103 Early Hints, and streaming HTML.
HTTP 103 Early Hints implementation details and browser support.