What Is Time to First Byte and Why Does It Matter?
Time to First Byte (TTFB) measures the duration between a user’s browser sending an HTTP request and receiving the very first byte of the response from the server. It is, in the simplest terms, the waiting time before your page even begins to load.
Think of it as the moment you ring a doorbell and wait for someone to answer. Everything that happens afterward — rendering HTML, loading CSS, displaying images — cannot begin until that door opens.
TTFB in the Context of Core Web Vitals
Google officially integrated TTFB into its performance framework. While TTFB is not a Core Web Vital itself, it is a critical precursor to Largest Contentful Paint (LCP), which is one of the three Core Web Vitals. The math is simple:
- If your TTFB is 1.5 seconds, your LCP cannot be under 1.5 seconds.
- Google’s “good” threshold for LCP is 2.5 seconds.
- That leaves you barely one second for every other rendering task.
Google’s own documentation recommends a TTFB of 800ms or less. Elite sites routinely achieve 100–200ms.
The Business Impact of Slow TTFB
Performance is not an abstract engineering concern. It’s revenue.
- Amazon found that every 100ms of latency costs them 1% in sales.
- Google reported that a 500ms delay in search results reduced traffic by 20%.
- Walmart observed a 2% increase in conversions for every 1-second improvement in load time.
A slow TTFB is the invisible bottleneck that undermines every other optimization you make. You can compress images, minify CSS, and defer JavaScript all you want — if the server takes two seconds to respond, the user is already gone.
Anatomy of TTFB: What Happens in Those Milliseconds
To fix TTFB, you need to understand what constitutes it. The total TTFB is the sum of three distinct phases:
| Phase | Description | Typical Duration |
|---|---|---|
| DNS Lookup | Resolving the domain name to an IP address | 20–120ms |
| TCP/TLS Connection | Establishing the connection and negotiating encryption | 50–200ms |
| Server Processing | The server receiving the request, executing application logic, querying databases, and generating the response | 50–2000ms+ |
The third phase — server processing time — is where the vast majority of TTFB problems originate. DNS and connection times are largely governed by geography and protocol, but server processing is entirely within your control.
Breaking Down Server Processing Time
Within the server processing phase, several operations occur sequentially or in parallel:
- Web server receives the request (Nginx, Apache, LiteSpeed)
- Application runtime interprets the code (PHP, Node.js, Python)
- Database queries execute (MySQL, PostgreSQL, Redis lookups)
- Template rendering and response generation
- Response sent back to the web server and then to the client
A bottleneck at any of these stages inflates your TTFB.
Diagnosing TTFB: A Systematic Approach
Before you optimize anything, you need a clear diagnosis. Guessing leads to wasted effort. Here is the diagnostic workflow we recommend — and the same methodology used by Lueur Externe when auditing client sites for performance.
Step 1: Measure Baseline TTFB
Use multiple tools to establish a reliable baseline:
- Google PageSpeed Insights — Provides field data (real users) and lab data.
- WebPageTest.org — Allows testing from different global locations with detailed waterfall charts.
- Chrome DevTools (Network tab) — Shows the “Waiting (TTFB)” value for every request.
- curl from the command line — Quick, scriptable, and eliminates browser overhead.
Here’s a quick curl command to measure TTFB precisely:
curl -o /dev/null -s -w "DNS: %{time_namelookup}s\nTCP: %{time_connect}s\nTLS: %{time_appconnect}s\nTTFB: %{time_starttransfer}s\nTotal: %{time_total}s\n" https://www.example.com
Sample output:
DNS: 0.024s
TCP: 0.058s
TLS: 0.121s
TTFB: 0.873s
Total: 1.204s
In this example, the TTFB is 873ms. Subtracting the TLS handshake time (121ms), the server processing time is roughly 752ms — that is where the problem lies.
Step 2: Isolate the Bottleneck Layer
Run the same test from the server itself (e.g., curl localhost). If TTFB drops to 100ms, the issue is network-related (CDN, DNS, or geographic distance). If it remains high, the problem is in your application stack.
Step 3: Profile the Application
For WordPress or PrestaShop sites, enable query logging and use profiling tools:
- WordPress: Install Query Monitor to see slow database queries and hook execution times.
- PrestaShop: Use the Debug Profiler (Symfony debug toolbar in 1.7+/8.x) to inspect module load times.
- General PHP: Enable
XdebugorBlackfire.ioprofiling to get a full flame graph of execution. - Node.js: Use built-in
--profor tools like Clinic.js.
Look for:
- Database queries taking >50ms each
- External API calls that block rendering
- Modules or plugins executing heavy logic on every request
- Unoptimized loops or redundant computations
Step 4: Check Server Resources
Sometimes the code is fine but the server is starved:
- CPU usage — Sustained >80% indicates under-provisioning.
- RAM — If swap is active, you’re already too late.
- Disk I/O — Spinning HDDs have no place in production hosting in 2025. NVMe SSDs are the minimum.
- PHP-FPM pool saturation — If all workers are busy, requests queue.
# Check PHP-FPM pool status
curl -s http://localhost/status?full | grep -E "(active|idle|listen queue)"
Solutions: How to Reduce TTFB
Now that you know where the problem is, let’s fix it. We’ll work from the highest-impact, lowest-effort solutions down to deeper architectural changes.
Server-Side Caching (The Single Biggest Win)
If you implement one optimization from this entire article, make it full-page caching.
Full-page caching stores the fully rendered HTML output and serves it directly on subsequent requests, bypassing PHP execution and database queries entirely.
Results we typically see:
| Scenario | TTFB Before | TTFB After | Improvement |
|---|---|---|---|
| WordPress without caching | 1.2–2.5s | 80–150ms | ~90% |
| PrestaShop product pages | 800ms–1.8s | 60–120ms | ~92% |
| Custom PHP application | 600ms–1.5s | 40–100ms | ~93% |
Implementation options by stack:
- Nginx FastCGI Cache — Extremely fast, operates at the web server level before PHP is even invoked.
- Varnish Cache — A dedicated HTTP reverse proxy cache, powerful but adds architectural complexity.
- Redis/Memcached object caching — Caches database query results and application objects; complements full-page caching.
- WordPress plugins — WP Super Cache, W3 Total Cache, or WP Rocket (premium).
- PrestaShop — Built-in Smarty/Symfony cache + a reverse proxy in front.
Here’s a basic Nginx FastCGI cache configuration:
# In the http block
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=WPCACHE:100m inactive=60m max_size=1g;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
# In the server/location block
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
fastcgi_cache WPCACHE;
fastcgi_cache_valid 200 60m;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
add_header X-Cache-Status $upstream_cache_status;
}
Database Optimization
Slow queries are the second most common TTFB killer. Here’s a checklist:
- Enable the slow query log (
long_query_time = 0.5) and review it weekly. - Add missing indexes. A single missing index on a WHERE clause can turn a 10ms query into a 2-second table scan.
- Optimize tables regularly —
OPTIMIZE TABLEfor InnoDB removes fragmentation. - Use persistent connections to avoid TCP handshake overhead on every query.
- Tune MySQL/MariaDB buffers:
innodb_buffer_pool_sizeshould be ~70-80% of available RAM on a dedicated DB server.query_cache_type = OFFon MySQL 8+ (deprecated; use ProxySQL or application-level caching instead).
PHP Optimization
- Upgrade PHP. PHP 8.3 is up to 40% faster than PHP 7.4 on real-world WordPress benchmarks.
- Enable OPcache with aggressive settings:
opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0 ; Set to 1 in development
opcache.jit_buffer_size=128M
opcache.jit=1255
- Tune PHP-FPM — Use
pm = staticwith the number of children calculated as:(Total RAM - OS/DB overhead) / average PHP worker memory. - Disable unused extensions to reduce interpreter startup overhead.
Implement a CDN
A Content Delivery Network places cached copies of your content on edge servers worldwide, reducing the geographic latency component of TTFB.
- Cloudflare — Free tier includes basic CDN; Pro ($20/mo) adds Polish, Mirage, and better cache rules.
- AWS CloudFront — Excellent for sites hosted on AWS infrastructure. As an AWS Solutions Architect certified agency, Lueur Externe frequently architects CloudFront distributions integrated with S3, EC2, or Lambda@Edge for maximum performance.
- Fastly / KeyCDN / Bunny.net — Strong alternatives depending on use case and budget.
Pro tip: Configure your CDN to cache HTML pages for logged-out users (not just static assets). This alone can drop TTFB to under 50ms globally.
Upgrade Your Hosting
Shared hosting is the enemy of consistent TTFB. When your PHP processes compete with hundreds of other sites on the same server, performance is unpredictable.
The hosting progression for serious websites:
- Shared hosting — Acceptable for hobby sites. TTFB: 500ms–3s.
- Managed WordPress/PrestaShop hosting — Better isolation. TTFB: 200ms–800ms.
- VPS / Cloud instances (AWS EC2, DigitalOcean, Hetzner) — Full control. TTFB: 100ms–400ms.
- Dedicated server with NVMe and tuned stack — Peak performance. TTFB: 50ms–200ms.
- Edge computing / serverless (Lambda@Edge, Cloudflare Workers) — Near-zero TTFB for cached logic.
Reduce External Dependencies
Every external API call during page generation adds its own latency:
- Payment gateway status checks at render time? Cache them.
- Geolocation API calls on every request? Cache results by IP prefix.
- Remote font loading in PHP templates? Preload or self-host fonts.
- Third-party inventory or ERP sync on page load? Move to asynchronous background jobs (cron, message queues).
A single slow API call can add 500ms–2s to your TTFB, and you have zero control over that third party’s response time.
Optimize TLS Handshake
The TLS negotiation is often overlooked:
- Enable TLS 1.3 — Reduces the handshake from 2 round trips (TLS 1.2) to 1, saving 50–100ms.
- Enable OCSP Stapling — Eliminates the browser’s separate request to verify your SSL certificate.
- Use HTTP/2 or HTTP/3 — Multiplexing and header compression reduce overhead on subsequent requests.
- Session resumption — TLS session tickets allow returning visitors to skip most of the handshake.
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
ssl_session_tickets on;
ssl_stapling on;
ssl_stapling_verify on;
Real-World Case Study: From 2.1s to 140ms
To illustrate the cumulative impact of these optimizations, here’s a composite example based on common patterns we encounter in our performance audits at Lueur Externe:
Starting point: A PrestaShop 8 e-commerce store with 15,000 products, hosted on a basic cloud VPS, no CDN, no server-side caching.
- Initial TTFB: 2,100ms (homepage), 2,800ms (category pages)
Optimizations applied, in order:
| Step | Action | TTFB After |
|---|---|---|
| 1 | Upgraded PHP 7.4 → 8.3 with JIT enabled | 1,400ms |
| 2 | Enabled OPcache with aggressive settings | 1,200ms |
| 3 | Added missing database indexes on ps_product and ps_category_product | 850ms |
| 4 | Tuned MySQL innodb_buffer_pool_size to 2GB | 720ms |
| 5 | Disabled 8 unused PrestaShop modules loading on every page | 550ms |
| 6 | Implemented Nginx FastCGI full-page caching | 140ms |
| 7 | Added CloudFront CDN for global edge delivery | 45–90ms (depending on region) |
Final TTFB: 45–140ms depending on cache status and geography.
That is a 93–98% reduction — achieved without rewriting a single line of application code.
Monitoring TTFB Over Time
Optimizing TTFB is not a one-time task. Traffic spikes, plugin updates, database growth, and content changes can all degrade performance. Set up continuous monitoring:
- Google Search Console — The Core Web Vitals report shows TTFB-related issues at scale.
- Real User Monitoring (RUM) — Tools like SpeedCurve, Datadog RUM, or even the free
web-vitalsJavaScript library capture actual user TTFB. - Synthetic monitoring — Pingdom, UptimeRobot, or custom scripts running
curlon a cron schedule. - Alerts — Set a threshold (e.g., TTFB > 500ms) and get notified before your users notice.
// Capture TTFB using the PerformanceObserver API
new PerformanceObserver((list) => {
const navigation = list.getEntries()[0];
const ttfb = navigation.responseStart - navigation.requestStart;
console.log(`TTFB: ${ttfb.toFixed(0)}ms`);
// Send to your analytics endpoint
}).observe({ type: 'navigation', buffered: true });
Common Mistakes to Avoid
Even experienced developers make these errors:
- Caching only static assets. Images and CSS are not your TTFB bottleneck — HTML generation is.
- Ignoring mobile TTFB. Mobile connections have higher latency; test on throttled connections.
- Using too many WordPress plugins. Each plugin can add 10–200ms of PHP execution time. Audit ruthlessly.
- Not testing from multiple locations. A site that’s fast from your office in Paris might have 1.5s TTFB in Tokyo.
- Over-relying on a CDN. A CDN cannot fix slow origin server response. Fix the origin first.
- Forgetting cache invalidation. Stale caches serve outdated content. Design your cache strategy with clear invalidation rules.
Conclusion: TTFB Is the Foundation of Web Performance
Time to First Byte is the invisible metric that determines the ceiling for every other performance indicator on your site. You cannot have a fast LCP with a slow TTFB. You cannot deliver a great user experience if the server takes two seconds to start talking.
The good news? TTFB is entirely solvable. With the right diagnostic approach and a methodical stack of optimizations — from PHP upgrades and database tuning to full-page caching and CDN deployment — you can routinely achieve sub-200ms TTFB on even complex e-commerce sites.
If you’re unsure where your bottleneck is, or if you’ve tried optimizations without meaningful results, it may be time to bring in specialists. Lueur Externe has been helping businesses achieve peak web performance since 2003, with deep expertise in PrestaShop, WordPress, and AWS infrastructure. We don’t guess — we measure, diagnose, and deliver measurable improvements.