← All articles

Web Performance · Server Response

TTFB Explained: How to Measure and Improve Server Response Time

Illustration of a stopwatch between a browser and a web server

Concept illustration, not a screenshot or measured test result.

What Is TTFB?

TTFB means Time to First Byte. It is a web performance measurement describing the delay before the client receives the first byte of an HTTP response. When someone opens a website, the browser needs to locate the relevant server, establish or reuse a connection, make a request, and wait for the reply to begin. TTFB helps show how quickly the first response becomes available.

A slow initial response can delay later loading steps, because the browser cannot start processing the requested HTML until it receives it. Nevertheless, TTFB is not a complete measure of website speed. A page can have a fast response and still render slowly because of large images, heavy JavaScript, blocked resources, or inefficient client-side code.

It is also misleading to treat TTFB as identical to application execution time. Redirects, network latency, connection establishment, caching, and infrastructure may all influence the value. The useful question is not merely “Is this number high?” but “Which part of the delivery path is responsible?”

Illustration of a cached response travelling from servers to a browser

Concept illustration, not a screenshot or measured test result.

How Does Time to First Byte Work?

The browser prepares a request

The browser resolves the relevant destination and may establish a network connection with encryption. Existing connections and cached DNS information can reduce some of these costs. A navigation that follows redirects can include additional round trips before the final response is received.

The request reaches the delivery infrastructure

The request may pass through a content delivery network, reverse proxy, load balancer, application server, and database. A cached HTML document can sometimes be returned quickly. A dynamic page may require authentication, data retrieval, rendering, or external API calls before the first byte is sent.

The initial response arrives

The first response byte reaches the browser. Measurement tools can report different timing scopes. Full navigation TTFB can include early phases such as DNS and connection setup, whereas a browser network panel may separately display the waiting period after sending a request. Understand the exact definition before comparing numbers from unrelated tools.

What Is a Good TTFB?

Google's web.dev guidance provides useful general thresholds:

TTFB General interpretation
800 ms or less Good
Above 800 ms up to 1,800 ms Needs improvement
More than 1,800 ms Poor

These thresholds are diagnostic guidance, not promises of conversion rates or search rankings. They should be considered alongside the experience of real visitors. A single test from a nearby data center may look much faster than a visit from a mobile device on a congested connection.

For field metrics, a 75th-percentile value is commonly examined. This helps evaluate the experience across many visits rather than focusing on the fastest request. Even a good TTFB does not guarantee that a page will become visible or interactive quickly.

Is TTFB a Core Web Vital?

No. TTFB is a supporting performance metric, not one of the Core Web Vitals. Core Web Vitals measure important aspects of loading, responsiveness, and visual stability. TTFB still matters because a delay before the first HTML byte can affect later loading milestones. Analyze it with other performance measurements instead of treating it as the only objective.

How to Check TTFB in Chrome

Step 1: Open Developer Tools

Open the page in Chrome. Right-click and choose Inspect, or use the appropriate keyboard shortcut. Select the Network panel. If no requests appear, make sure recording is enabled.

Step 2: Reload and select the document

Refresh the page while the Network panel is visible. Find the main document request, usually associated with the page URL. Do not confuse it with requests for a font, image, script, advertisement, or analytics service. Each resource has its own timing, so selecting the wrong row can produce an irrelevant result.

Step 3: Inspect Timing

Open the request and select the Timing tab. Look for a phase labeled Waiting for server response, or TTFB. The panel may also show queuing, DNS lookup, connection, request sending, and content download phases. Review the complete breakdown: a long wait can involve backend processing or network delay, but it does not establish the exact cause.

Step 4: Repeat the measurement

Run several tests, and note whether caching is enabled. A warm request may reuse an existing connection or cached response and perform differently from the first visit. Measure representative pages, not just your homepage. Where possible, test from regions that match your audience.

How to Measure TTFB With JavaScript

The browser Performance API exposes navigation timing information. One example is:

const navigation = performance.getEntriesByType("navigation")[0];

if (navigation) {
  const requestWait = navigation.responseStart - navigation.requestStart;
  console.log(`Request-to-first-byte: ${requestWait.toFixed(0)} ms`);
}

This calculation measures the interval from the start of the navigation request until its first response byte. It is narrower than a full TTFB measurement that also includes earlier navigation phases. Do not present it as an identical replacement for every monitoring service's number.

Browser APIs, caching, cross-origin restrictions, and timing implementations can affect what is exposed. For consistent comparisons, use the same tool, definition, environment, and methodology. Document the conditions if you are evaluating a deployment change.

Lab TTFB vs. Real-User TTFB

Laboratory measurements

Lab tests run under selected conditions. They are useful for investigation because you can repeat requests, compare versions, and isolate changes. However, they reflect the chosen device, location, network, and cache state. One laboratory result cannot represent the entire audience.

Field measurements

Field data is collected from real browsing experiences and includes the variation produced by devices, networks, and geography. Aggregated datasets such as the Chrome User Experience Report may provide useful information when sufficient traffic exists. Field data is helpful for judging whether actual visitors benefit from optimizations.

Why both matter

Lab testing helps explain a problem; field data helps show its real-world impact. For example, optimizing an expensive query might immediately improve a controlled test while broader user metrics change more gradually. Use both before declaring that a complex performance issue has been solved.

Why Is My TTFB High?

Slow application processing

An application may need to authenticate users, render templates, or calculate results before returning HTML. Expensive operations increase the delay. Server-side profiling, application logs, and timing headers can reveal where the time is spent. Optimize the most expensive verified step rather than guessing from the front end.

Inefficient database queries

Dynamic pages may wait for database queries, locks, or remote data. Queries that retrieve unnecessary columns, scan large tables, or repeat work can slow the response. Use execution plans and representative data to understand the bottleneck. Indexing can help some query patterns, but an index should not be added blindly.

Missing or ineffective caching

Without caching, a server may regenerate the same public page for every request. Appropriate caching reduces repeated work. However, personalized responses must be handled carefully: a cache misconfiguration can expose private data or serve the wrong person's content. Choose policies that reflect freshness and privacy requirements.

Network distance and routing

A visitor far from the origin may experience additional latency. Routing problems, packet loss, or congestion can also affect response delivery. A content delivery network may bring suitable cacheable content closer to users, but it cannot automatically fix slow uncached application logic.

Redirect chains

Multiple unnecessary redirects add round trips before the final document arrives. Review domain changes, old URLs, and HTTP-to-HTTPS handling. Preserve legitimate security redirects but update internal links to the canonical destination and remove avoidable intermediate hops.

Slow external services

Server-rendered pages sometimes wait for third-party APIs. A slow upstream call can delay the entire HTML response. Consider timeouts, caching, parallel operations, and whether the external information truly needs to be fetched before the first byte is sent.

How to Reduce TTFB Step by Step

1. Establish a baseline

Measure several requests with the same tool. Record the URL, date, test location, connection conditions, and cache status. Include representative routes such as product pages, articles, and account screens if they matter to visitors. Without a baseline, a later change may feel faster while offering no measurable improvement.

2. Trace server-side operations

Inspect logs and application instrumentation to determine which operations occur before the response starts. Break down database time, rendering, authentication, external calls, and queue delays. Prioritize the operations that consistently contribute the most time.

3. Use safe caching

Cache suitable public HTML, assets, or repeated computations. Use sensible expiration and invalidation rules. Avoid sharing personalized responses through public caches. Validate that a cached page remains accurate after content changes and that private information never leaks between users.

4. Improve database access

Retrieve only the data required for the response, minimize redundant queries, and review expensive execution plans. Database indexes, schema changes, or query rewrites may help, but measure their effect. A faster query can reduce TTFB while also limiting unnecessary resource use.

5. Reduce redirects and dependencies

Point internal links to their final destinations and remove unnecessary redirect hops. Examine synchronous dependencies that delay every page. Where architecture permits, postpone nonessential work until after the initial response or use appropriate caching and timeouts.

6. Review infrastructure and CDN settings

Consider geographic distribution, origin capacity, cache hit rates, connection reuse, and deployment location. Scaling resources may help when the server is genuinely constrained, but paying for a larger server rarely fixes a poor query or a repeated external API call by itself.

7. Verify with field data

After deployment, measure under comparable conditions and track real-user trends. Look for sustained improvement rather than one exceptionally fast request. Continue monitoring other performance metrics so that an improvement in TTFB does not conceal a new rendering or responsiveness problem.

How Does TTFB Affect Largest Contentful Paint?

Largest Contentful Paint, or LCP, describes when the largest relevant content element becomes visible in the viewport. TTFB occurs earlier. If the browser waits too long for initial HTML, it may discover critical text, images, styles, or scripts later, contributing to a slower LCP.

The relationship is not automatic. A site can have good TTFB but poor LCP because an important image is requested late or the page is blocked by JavaScript. Conversely, improving TTFB may help LCP without resolving every loading bottleneck. Analyze the sequence from server response through resource discovery and rendering rather than optimizing one number in isolation.

Does a Faster Server Always Mean Better TTFB?

Not necessarily. TTFB includes effects outside raw application processing. A powerful origin far from its audience may still produce noticeable latency. A smaller server with efficient caching can respond quickly to appropriate requests. Connection setup, routing, and redirects all contribute to what the visitor observes.

Before upgrading hosting, determine whether the bottleneck is CPU capacity, database operations, upstream dependencies, network distance, or cache configuration. Infrastructure spending should follow evidence rather than a general belief that more resources always means faster delivery.

Common Measurement and Optimization Mistakes

Testing only the homepage overlooks slow template or database routes. Comparing a cached lab request against an uncached field request produces misleading conclusions. Treating TTFB as total page-load time ignores rendering and interaction delays. Disabling protective controls or caching private content to gain speed can create much more serious problems than a slow response.

Also avoid reacting to one anomalous measurement. Network conditions naturally vary. Look at distributions, repeated tests, and sustained trends. When a change improves one metric but worsens another, evaluate the complete visitor experience before deciding whether to keep it.

Frequently Asked Questions

What is TTFB?

Time to First Byte measures the delay until the first byte of an HTTP response is received by the client.

What is a good TTFB?

Google's general guidance treats 800 milliseconds or less as good and more than 1,800 milliseconds as poor. Context and measurement conditions still matter.

How do I reduce TTFB?

Investigate server processing, database queries, caching, redirects, network latency, and external dependencies. Optimize the largest verified causes.

How do I check TTFB in Chrome?

Open Developer Tools, choose Network, reload, select the main document request, and inspect its Timing details.

Is TTFB the same as server response time?

The terms overlap, but a complete navigation TTFB can include network and connection delays beyond the application's own execution time.

Is TTFB a Core Web Vital?

No. It is an important supporting metric for understanding loading performance.

Can a CDN improve TTFB?

Yes, especially for cacheable content served to geographically distributed users. The effect depends on architecture and cache behavior.

Conclusion

TTFB tells you how quickly a website begins to respond, not when the page is fully loaded. Measure it consistently, separate network costs from backend work, improve confirmed bottlenecks, and verify the result across real users. Combine TTFB with LCP, latency, and broader loading measurements for a realistic understanding of website performance.

Official references

← All articles