What is TTFB
TTFB (Time to First Byte) is the time from when the browser sends an HTTP request until it receives the first byte of the server’s response. It is measured in milliseconds and is a fundamental metric for server response speed.
TTFB includes:
- DNS lookup — time to resolve the domain name to an IP address
- TCP connection — establishing a TCP connection to the server
- TLS handshake — for HTTPS: negotiating SSL/TLS
- Server processing — time the server takes to process the request
- Transfer time — time for the first byte of data to reach the browser
Google included TTFB in its Page Experience assessment as an LCP sub-metric. A slow TTFB directly worsens LCP.
TTFB thresholds
| Value | Rating |
|---|---|
| up to 800 ms | Good |
| 800–1800 ms | Needs improvement |
| over 1800 ms | Poor |
Note: Google does not officially classify TTFB as a Core Web Vitals metric, but it is an important diagnostic indicator for LCP.
How to improve TTFB
1. Server-side caching
The most effective method is to avoid generating the page every time:
# Nginx + FastCGI кеш
fastcgi_cache_path /tmp/nginx-cache levels=1:2 keys_zone=mycache:10m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
location ~ \.php$ {
fastcgi_cache mycache;
fastcgi_cache_valid 200 1h;
}For Next.js, use ISR (Incremental Static Regeneration) or full SSG:
// getStaticProps с revalidate = кеш на сервере
export async function getStaticProps() {
return {
props: { data },
revalidate: 3600 // Обновлять раз в час
};
}2. CDN for static pages
Cloudflare, Vercel Edge Network, and AWS CloudFront cache HTML responses on edge servers close to the user.
3. Database optimization
Poor TTFB is often caused by slow database queries:
-- Анализ медленных запросов
EXPLAIN ANALYZE SELECT * FROM products WHERE category = 'phones';
-- Добавить индекс для ускорения
CREATE INDEX idx_products_category ON products(category);4. Reduce DNS lookup time
<!-- DNS prefetch для критических доменов -->
<link rel="dns-prefetch" href="//api.example.com" />
<link rel="preconnect" href="https://fonts.googleapis.com" />5. TLS optimization
# TLS 1.3 быстрее TLS 1.2 (1-RTT vs 2-RTT)
ssl_protocols TLSv1.2 TLSv1.3;
# Session resumption
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
# OCSP Stapling
ssl_stapling on;
ssl_stapling_verify on;6. Upgrade the server
- Switching from shared hosting to a VPS improves TTFB by 3-5x
- A server physically closer to the audience reduces transfer time
Measuring TTFB
# curl показывает все фазы подключения
curl -o /dev/null -s -w "
TTFB: %{time_starttransfer}s
Total: %{time_total}s
" https://example.comIn Chrome DevTools → Network → select a request → Timing → “Waiting for server response” = TTFB.
Check TTFB on reChecker
Use Web Vitals to check your server response time. The tool will show:
- Your website’s TTFB
- All Core Web Vitals metrics
- Overall performance rating
FAQ
Is TTFB more important than LCP for SEO? LCP matters more directly for rankings (it is an official CWV metric). TTFB matters as a prerequisite for LCP: if TTFB is poor, it is almost impossible to bring LCP within the normal range without fixing TTFB.
How can TTFB be good but the page still be slow? TTFB measures only the first byte. After that, the browser still has to load CSS, JavaScript, and images. A site with a TTFB of 300 ms but 5 MB of JavaScript will load slowly.
Does a CDN always improve TTFB? A CDN is very helpful for static resources and cacheable HTML pages. For dynamic pages (personalization, data from a database), the CDN does not cache the response, so the request must go to the origin server.