All posts

Blog

How to Reduce TTFB (Time to First Byte) on Your Website

Illustrated cover for the Speed & Performance guide "How to Reduce TTFB (Time to First Byte) on Your Website"

Before a browser can show a single word or image from your site, it has to wait for your server to send back the first piece of the page. That wait is called time to first byte, or TTFB. If it is slow, nothing else can start: not the CSS, not the images, not the layout.

The good news is that TTFB is usually one of the most fixable speed problems. This guide explains what goes into it, how to measure it properly, and how to reduce it step by step.

What TTFB actually measures

TTFB is the time from when the browser starts requesting a page to when the first byte of the response arrives. It isn't just "how fast your server is." It includes:

  1. Redirects, if the URL bounces (for example http:// to https:// to www)
  2. DNS lookup, turning your domain into an IP address
  3. Connection setup, the TCP connection and the TLS (HTTPS) handshake
  4. Network travel time to your server and back
  5. Server processing, where your application builds the page

That's why TTFB can be slow even when your server is fast, for example when a visitor is on the other side of the world or the page goes through a chain of redirects.

What is a good TTFB?

Google's web.dev guidance suggests aiming for a TTFB of roughly 0.8 seconds or less for most sites, as measured from real users. Lower is better, of course, and cached pages served close to the visitor are often much faster than that. TTFB isn't one of the Core Web Vitals itself, but it directly affects Largest Contentful Paint, because nothing can paint until the HTML arrives. Our guide to Core Web Vitals covers how they fit together.

How to measure TTFB properly

Measure several times and from different places, because a single test can mislead you.

  • Browser developer tools: open the Network tab, reload, click the main document, and open the Timing panel. "Waiting for server response" is the server-side portion.
  • PageSpeed Insights: shows real-user TTFB data (when your site has enough traffic) along with lab tests.
  • WebPageTest: lets you test from different locations and shows a waterfall with DNS, connection and TLS broken out.
  • curl: a quick command-line check:
curl -o /dev/null -s -w "DNS: %{time_namelookup}  Connect: %{time_connect}  TLS: %{time_appconnect}  TTFB: %{time_starttransfer}\n" https://example.com/

Test both a cached page (your homepage, visited twice) and an uncached one (try a logged-in page or add a random query string). The difference tells you how much caching is doing for you. More tools are covered in how to test website speed.

Step 1: Add page caching (the biggest win)

For a WordPress or other CMS site, the server-processing part of TTFB is usually dominated by PHP and database work. A page cache serves pre-built HTML instead, skipping nearly all of it.

If your uncached pages are slow but cached ones are fast, caching is working and the remaining steps will improve the uncached experience.

Step 2: Remove redirect chains

Every redirect adds a full round trip before the real page even starts. Common chains:

  • http://example.com to https://example.com to https://www.example.com
  • Old URLs redirected to other old URLs before reaching the current page

Make sure links, menus and your canonical settings point directly at the final URL, and collapse chains into a single hop.

Step 3: Speed up the uncached work

Some pages can't be cached: carts, checkouts, dashboards, search results. To make those faster:

  • Use a current PHP version. Newer PHP releases are generally faster and receive security fixes.
  • Make sure OPcache is enabled so PHP doesn't recompile code on every request.
  • Add a persistent object cache such as Redis for dynamic sites with heavy database use.
  • Clean up the database, especially oversized autoloaded options in WordPress.
  • Audit plugins. Use Query Monitor to find plugins running slow queries or making slow external API calls during page loads. One badly behaved plugin can add seconds. Our post on how many plugins is too many explains why quality matters more than count.

Step 4: Reduce distance with a CDN

Network latency grows with distance. If your server is in one region and many visitors are far away, every round trip (DNS, connection, TLS, request) costs more.

  • Choose a server location near most of your visitors. See how to choose a server location.
  • Use a CDN to serve static files from nearby, and consider edge caching of HTML for content that is the same for everyone.

Step 5: Make DNS and connections faster

  • Use a fast DNS provider. Many CDNs and registrars run large DNS networks.
  • Enable HTTP/2 or HTTP/3 so connections are reused efficiently and set up faster.
  • Use TLS 1.3, which needs fewer round trips to set up a secure connection than older versions. Most modern servers and CDNs support it.
  • Keep connections alive (keep-alive is on by default on most servers) so repeat requests don't reconnect.

Step 6: Check your hosting resources

If uncached TTFB swings wildly, slow at some times and fine at others, your site may be running into resource limits such as CPU, memory or the number of simultaneous processes. Our guide to hosting resource limits explains what those numbers mean. Look at your control panel's resource usage graphs during slow periods.

Common causes include traffic spikes, aggressive bots crawling the site, heavy cron jobs running during busy hours, and backups running at the same time as peak traffic. If you consistently hit limits even after optimizing, it may be time to look at moving from shared hosting to a VPS.

Step 7: Watch for slow external calls

Some themes and plugins make requests to outside services (license checks, social feeds, analytics APIs) while building the page. If that service is slow, your TTFB is slow. Query Monitor and server logs can reveal these HTTP calls. Fixes include caching the results, loading the content with JavaScript after the page renders, or removing the feature.

A quick TTFB troubleshooting checklist

  1. Is the slow TTFB on cached pages, uncached pages or both?
  2. Is it slow from everywhere, or only far from the server?
  3. Are there redirects before the final URL?
  4. Is page caching active and getting hits?
  5. Is PHP up to date with OPcache enabled?
  6. Does Query Monitor show slow queries or slow external requests?
  7. Are you hitting resource limits during slow periods?

Wrapping up

TTFB is the first domino in page speed: when it is slow, everything after it is slow too. Measure it properly from more than one location, then work through the fixes in order of impact: page caching, removing redirects, speeding up uncached PHP and database work, bringing content closer with a CDN and the right server location, and making sure your hosting isn't hitting its limits. Most sites can bring TTFB down dramatically with just the first two steps.