How to diagnose high TTFB and reduce server response time

Short answer

Measure a GET for the HTML document and compare first-byte time with request waiting in DevTools. If it waits after the connection opens, compare cache behavior and instrument application stages with Server-Timing. If the delay comes earlier, inspect DNS, TLS, and redirects.

Read the guide
Share

Summarize with ChatGPT or Perplexity

How to diagnose high TTFB and reduce server response time

Download the evidence (JSON)

How to diagnose high TTFB and reduce server response time

TTFB is the time to the first byte of HTML, not a general “site speed” score. web.dev recommends focusing on initial server response because it controls how soon the browser can start parsing HTML and discovering subresources. High TTFB can come from geography, TLS, redirects, server queueing, slow application code, or missing cache. Source: web.dev/optimize-ttfb.

The evidence here comes from a local HTTP fixture with three MISS/HIT pairs. Both variants returned the same HTML. The fixture simulated a 180 ms backend wait on MISS and skipped that wait on HIT. Recorded medians:

  • MISS: TTFB 191.3 ms, requestWait 189.7 ms, app 188.4 ms;
  • HIT: TTFB 1.5 ms, requestWait 0.6 ms, app 0 ms.

This is not production CDN data, not live traffic, and not DNS/TLS timing. Keep the conclusion narrow: this fixture demonstrates how server-side waiting dominates TTFB when the response path is uncached.

TTFB vs server response time: read the metrics correctly

In browser APIs, TTFB is commonly derived as responseStart - startTime, while waiting for the response is responseStart - requestStart. For navigation entries, PerformanceNavigationTiming spans more than just server time, so you should not collapse it into a single server number without context. Source: MDN PerformanceNavigationTiming.

Server-Timing is useful because the server can expose named segments such as app;dur=188.4. But a header does not magically diagnose the root cause: it only reports what you instrumented on the server. Source: MDN Server-Timing.

Reproduce the TTFB measurement on your computer

Download the Node.js fixture, save it as ttfb-demo.mjs, and run node ttfb-demo.mjs. Send the request twice. The first response shows X-Demo-Cache: MISS, the second HIT. Restart the process for a fresh pair. On Windows, use curl.exe.

curl -sS -D headers.txt -o body.html -w "TTFB=%{time_starttransfer}s\n" http://127.0.0.1:8080/backend
Symptom Cause Check Fix Verification
TTFB is high only on MISS Application work or no cache Compare X-Demo-Cache, Server-Timing, and curl -w time_starttransfer Shorten the backend path, add cache for anonymous GET MISS and HIT diverge similarly to the recorded medians: ~191 ms vs ~1.5 ms
TTFB is high for every request Geography, TLS, redirects, or server overload Inspect redirect chains, server location, load, and network path Reduce redirects, move closer to users, remove bottlenecks TTFB drops without changing the HTML
Server-Timing is empty No instrumented server metric Confirm the server actually emits Server-Timing Add timing for the relevant server segment The header shows the expected app;dur
Recorded timings from three MISS/HIT pairs on the local server.
Recorded timings from three MISS/HIT pairs on the local server.

Rule of thumb: if HIT is fast but MISS is slow, the bottleneck is most likely server work or cache behavior, not browser rendering. If both are slow, look at network and infrastructure. This matches web.dev’s diagnostic approach and the need to separate browser timing from server telemetry. Sources: web.dev/ttfb, web.dev/optimize-ttfb.

Step-by-step diagnosis and fix

  1. Capture a baseline. Make 3–5 identical GET requests and record TTFB, time_starttransfer, response headers, and body.
  2. Compare MISS and HIT. If HIT is much faster, the slow path is before HTML generation or in uncached work.
  3. Inspect Server-Timing. Only trust segments that you actually instrumented, such as app. Do not infer the cause from one header alone.
  4. Check browser metrics. In DevTools or the Performance API, focus on responseStart, but do not confuse TTFB with LCP. LCP can change for reasons tied to resource discovery, not just first-byte latency.
  5. Fix the proven cause. If backend work is slow, optimize queries, templates, serialization, or blocking operations. If cache is the issue, cache only safe anonymous GET responses.

Caveat: do not cache personalized pages or requests with auth/cookies by default. For those cases, you need an explicit privacy and variation review. Also do not assume a CDN fix until you know whether the request is actually being served from cache.

For broader performance work, see the related internal articles: how to fix LCP image request discovery and compare Lighthouse reports before and after a release.

Break high TTFB into navigation phases

In DevTools Network, select the HTML request and open Timing. If Waiting for server response dominates, compare it with Server-Timing. If DNS, connection setup, or TLS dominates, changing application code will not explain that part of the delay. On a redirected route, record both the original and final URLs. Measuring only the latter omits the preceding step.

Here the median TTFB difference was 191.3 − 1.5 = 189.8 ms. On a MISS, the application timer reported 188.4 ms, consistent with the delay configured in the fixture. On a real site, compare browser and application records, group HIT and MISS separately, and account for geography. A loopback fixture cannot predict user latency.

For an anonymous page, compare status, content type, and body before and after changing caching. Check signed-in and personalized routes separately and keep them out of shared caches by default. Use the provider’s documentation to interpret a specific cache header.

FAQ

Why can TTFB be low while the page still feels slow?

Because TTFB measures only the first byte of HTML. Parsing, JavaScript, images, and LCP resources can still delay the user-visible result.

Can I diagnose TTFB from a single header?

No. Server-Timing reports only what the server instrumented. You still need browser-side timing and a MISS/HIT comparison.

Why is HEAD not a valid TTFB test here?

Because HEAD does not reproduce the full GET response path. Use GET for this measurement.

Should I fix cache or server code first?

Start by locating the delay. If HIT is much faster than MISS, cache or backend work is the best first target; if both are slow, investigate redirects, TLS, geography, or server load.

← Back to blog

Need help with your website?

Development and SEO services →

Related articles