time to first byte

How to Improve Time to First Byte (TTFB)

March 10, 2022

Time to first byte is the duration between the start of a request, and when the browser first receives data from the web server. If you're looking to improve your web site's page speed, then improving TTFB is a great place to start. There are many reasons for time-to-first-byte to be less than ideal. We'll cover the most common reasons for slow TTFB and how to improve it.

Table of Contents

What exactly is TTFB?

Simply put, TTFB measures how long it takes for the server to start responding. It's measured from the instant the browser begin loading a file, to when starts receiving data. This metric includes network latency, DNS lookup, the SSL handshake, and the server's processing of the request.

Lifecycle of an HTTP Request

When the browser requests any resource, there are a few different parts of this process before it starts receiving the file.

  1. First, the browser needs to know the IP address for the server. For example, in order to connect to google.com it needs to look up the IP address for that domain. The browser contacts a known DNS server to find the IP address.
  2. The browser establishes a TCP connection with the server. This is a three-way process between the client and server. The three steps are known as SYN, SYN/ACK, and ACK. With HTTP2, this connection will stay open to download multiple files from the same server. With HTTPv1, a new TCP connection must be opened for every request.
  3. For HTTPS requests, there's an additionally a TLS handshake. This allows the server to agree on what protocol to use and share the keys required for the client to send encrypted requests. This process has many steps, but if you want to learn more about how exactly it works, then Cloudflare has a great overview.
  4. Now, the browser can send the actual request. This includes which HTTP method is being used (such as GET or POST), a list of headers, and the resource being requested.
  5. The server receives the request, processes it, and sends data back over the TCP connection.

All of these steps are counted in the total TTFB metric. Most of this you don't have any control over, however, you can reduce how long it takes for the server to process the request, and reduce latency between the client and server.

How to measure TTFB?

There are various free page speed testing tools you can use online to measure TTFB. You can simply enter your website URL, and these tools will report back lots of useful information. We'll go over some of them below.


GTMetrix is a good tool for testing page speed in general, and it also reports a time to first byte metric. While this tool isn't the best for measuring overall speed, and its letter grade is overly optimistic, it's great for checking how your changes have improved TTFB. Running speed tests with PageSpeed Insights will give you better overall results, but less detailed data for diagnosing issues.

Web Page Test

WebPageTest is another general tool for testing lots of metrics related to pagespeed. It reports TTFB, as well as lots of other things, and is a great tool for diagnosing all pagespeed issues. You can choose between various devices and connection speeds, to see how your site performs under various conditions.

Byte Check

Byte Check is a tool dedicated to measuring TTFB. It will break down how long DNS lookup times are, SSL handshake times, and server processing. If you're looking for a simple app to quickly check TTFB, then this is it.

Google Chrome DevTools

The developer tools in Google Chrome also report TTFB. This is a good way to test time to first byte on your own computer. Keep in mind that TTFB will vary depending on geographical location, so even if from your machine it looks low, you should consider setting up a CDN for fast asset delivery to users located around the globe.

Why does time to first byte matter?

Time to first byte adds to the total load load of your pages. As the server processes requests from a user's browser, they'll see a blank page, regardless of the speed of their internet connection.

TTFB is important because it directly impacts your pagespeed. If you're doing SEO, then this matters because of Google's Core Web vitals. Google measures your page loads, and uses speed as a direct ranking factor to influence search rankings. Not only that, but bounce rate and loading times have a directly correlation, and bounce rate is another ranking factor.

Even if you're not doing SEO, then site speed is important. For example, if you're running paid traffic, then every user who clicks your ad and gets tired of waiting for the page to load is money wasted. For any traffic source, you're going to want to make the most of all of your website's visitors.

Use a Caching Plugin

If you're using a CMS like WordPress, then the server processing time may be slowing your TTFB down. Most web pages do not change on every request, and do not need to be treated as dynamic content. By using a cache plugin, your the HTML of your WordPress site will be saved as static content, and served to user without requiring the webpage to be regenerated.

Use a Content Delivery Network (CDN)

Even with caching enabled, and with a fast and properly configured web server, a content delivery network can greatly reduce server response times. Since data center location relative to the user will impact server response time, a CDN makes sure your files are always stored geographically close to the user.

A CDN can also reduce network latency even when users are located near the physical server. For example, when you use Cloudflare's CDN, fewer network hops are usually required to reach the server. Cloudflare, and other CDNs, have fast direct connections to ISP equipment, so users can access your files faster. With Cloudflare, you can even see a low TTFB around 50ms.

Use a Fast Web Host

Make sure your web server or host isn't slowing your site down. On some shared hosting plans, the server hardware is too weak to support the sites running on it very well. Rather than using a shared host, it's best to use a VPS provider like DigitalOcean, or use optimized WordPress hosting such as Kinsta or WP Engine. While a CDN can make up for this, it's best to keep your website's TTFB at a server level fast too.

Check Your Web Server Configuration

There are some server configuration issues that may cause a slower TTFB. You should make sure that the canonical versions of your URLs never redirect, and that you're always linking to canonical versions of resources. Each additional redirect is another request, and will slow down the load. If you're using complex firewall rules then this can increase how long it takes for the server to respond.


Improving time to first byte is an easy step you can take to improve your site's overall performance. Slow pages will drive users away, so the faster your site, the more users engage with your site, and the more leads, sales, conversions, or affiliate link clicks you'll get.

At Fastify, we've worked to perfect pagespeed. Check out the rest of our free resources to learn how you can speed up your site too. We also offer a step-by-step course that will show you exactly how to optimize your pages to make them as fast as possible.

Written By 
Mason Wiley
My name is Mason, and I cofounded Fastify after years of experience with SEO and affiliate marketing in a highly competitive industry. I've worked through countless pages of documentation and ran countless experiments to find all the hidden secrets to making screaming fast pages.