TTFBLCPFCPPerformanceCore Web Vitals

How to Fix Slow TTFB (Server Response Time) with AI

Diagnose and fix slow Time to First Byte (TTFB) over 800 ms using Lighthouse AIReport JSON and AI coding agents across Next.js, WordPress, and CDNs.

PageSpeed Exporter Team··4 min read

Time to First Byte (TTFB) measures how long the browser waits from requesting a URL until the first byte of HTML arrives—and Google recommends 800 ms or less. Because the browser cannot parse CSS, fetch hero images, or render text before HTML arrives, a slow TTFB directly inflates FCP, LCP, and Speed Index.

Using a stripped AIReport (<50KB) from PageSpeed Exporter, your AI coding agent can immediately tell whether slow LCP starts at the server (fixLocation: "server-cdn") and write the exact caching, CDN, or database fix.


TTFB Thresholds and Downstream Impact

TTFB RangeRatingTypical CauseImpact on LCP & FCP
| ≤ 200 ms | Excellent | Edge CDN / static HTML / full-page cache | Minimal overhead |

| 200–800 ms | Good | Fast origin SSR or warm regional cache | Passes Google guidance |

| 800–1,800 ms | Needs Improvement | Uncached SSR, slow DB queries, redirect chain | Makes ≤ 2.5 s mobile LCP hard |

| > 1,800 ms | Poor | Cold origin, heavy CMS plugins, distant server | Almost guarantees failing LCP |


Step 1: Confirm TTFB in Your AIReport

Run a live mobile audit at speedexporter.com (or call analyze_url via our MCP server) and inspect three places in the <50KB AIReport:

  1. resourceSummary.serverResponseTime: Your exact document TTFB in milliseconds.
  2. issues[] → server-response-time & redirects: Shows whether the origin itself is slow or whether redirect hops (http → https → www → apex) are burning 300–600 ms before the document even starts.
  3. LCP subparts (details.items with label / durationMs): Breaks LCP into TTFB, resource load delay, resource load duration, and element render delay. If TTFB is the largest slice, optimizing images first will not get you to 2.5 s.

Step 2: Prompt Your AI Agent with Server Context

Attach the AIReport to Claude, Cursor, or ChatGPT:

The attached JSON is a stripped PageSpeed Exporter AIReport for [URL].

1. Read resourceSummary.serverResponseTime, scorePlan, and the LCP subpart breakdown.
2. Tell me what percentage of LCP is spent waiting on TTFB or redirects.
3. Based on my stack ([Next.js on Vercel / WordPress on Kinsta / Shopify / Express + Postgres]), give me the exact config, caching header, or code change to cut TTFB below 400 ms.
4. Call out any dynamic auth/cookie checks or uncached queries that may be forcing dynamic rendering on public pages.

Highest-Leverage TTFB Fixes by Stack

Next.js (App Router)

  • Avoid accidental dynamic rendering: Calling cookies(), headers(), or uncached fetch(..., { cache: 'no-store' }) in a root layout forces every page request to wait on origin SSR. Keep public marketing and blog routes statically generated (○) or cached with ISR (export const revalidate = 3600).
  • Parallelize data fetches: Replace sequential await waterfalls with Promise.all([...]).
  • Add Cache-Control headers on public API/static endpoints: Use public, s-maxage=3600, stale-while-revalidate=86400 where safe.
  • See our Next.js performance optimization guide and Next.js platform page.

WordPress

  • Enable full-page caching: Without page caching, PHP + MySQL rebuild every HTML response from scratch. Install WP Rocket, FlyingPress, or server-level Nginx FastCGI cache.
  • Add a CDN with edge HTML caching: Cloudflare APO or a managed host's edge cache serves HTML within 50–150 ms globally.
  • Enable persistent object caching (Redis): Speeds up uncached WooCommerce/logged-in database queries.
  • See our WordPress Core Web Vitals 2026 guide and WordPress platform page.

Eliminate Redirect Chains (All Stacks)

Check meta.url vs meta.finalUrl in the AIReport. Every redirect hop adds a full network round trip on Slow 4G mobile (200–400 ms each). Ensure all internal links, sitemaps, and canonicals point directly to the final HTTPS apex/www URL with no trailing-slash bounce.


Step 3: Re-scan to Verify LCP & FCP Dropped

Deploy your caching or SSR change and run a fresh mobile audit in PageSpeed Exporter:

  • resourceSummary.serverResponseTime.numericValue ≤ 800 ms (ideally ≤ 400 ms).
  • largest-contentful-paint and first-contentful-paint in scorePlan drop by roughly the same milliseconds you shaved off TTFB.
  • On Starter (\$9/mo) or Pro (\$29/mo), use the before/after comparison view to verify both mobile and desktop TTFB improvements side by side.

Further Reading


Sources

Frequently Asked Questions

What is a good Time to First Byte (TTFB)?

Google recommends a TTFB of 800 ms or less. Static or CDN-cached HTML pages typically achieve 50–200 ms. A TTFB over 1,800 ms is considered poor and directly delays both FCP and LCP.

Does TTFB directly change the Lighthouse performance score?

TTFB does not have its own direct weight in the 0–100 Lighthouse score, but every millisecond of TTFB is added directly to FCP (10% weight), LCP (25% weight), and Speed Index (10% weight). Cutting TTFB from 1.8 s to 200 ms immediately shaves 1.6 s off LCP.

How do I know if my slow LCP is caused by TTFB or images?

Export a stripped AIReport JSON from PageSpeed Exporter and check the LCP subpart breakdown (lcp-breakdown-insight / details.items) alongside resourceSummary.serverResponseTime. If TTFB accounts for more than 40% of your LCP time, fix server response first.


Further reading

Try it yourself

Run a free Lighthouse audit on any URL and export a stripped AIReport JSON under 50KB for your AI agent — no account required.

Analyze a URL for free