Definition: What is Time to First Byte (TTFB)?
Time to First Byte refers to the time it takes for a browser to receive the first byte of response after a it made a request to the server. It sums up the time associated with each request phase like:
- DNS lookup
- TLS handshake
- SSL connection
In short, TTFB assesses the responsiveness of a web server and comes before any other useful loading performance statistics. It is measured in milliseconds.
It’s a frequent misperception that TTFB and HTTP request TTFB is the same. TTFB measures the sum of the time required for DNS lookup, TLS handshake, SSL connection and server response time for HTTP request. However, HTTP request TTDB only measures the server response time for HTTP request.
Why Is TTFB Important?
TTFB determines whether a web server is responding to queries slowly. If the value of TTFB is higher, it means it is taking longer for the data to reach you from the web server.
Google states that the likelihood of a user leaving a website rises by about 32% for every extra second it requires for your site to load. And if a visitor leaves your website quickly, they are likely not to come back. This behavior is more pronounced if they locate an alternative website that is faster and offers a similar service.
So, the TTFB is a crucial web vital because it is a measured before any other Web Vitals like Cumulative Layout Shit (CLS), Largest Contentful Paint (LCP), and First Input Delay (FID). If TTFB is slow, it affects all other Web Vitals.
By measuring TTFB along with other Web Vitals, you can get a holistic view of your website’s performance and identify where delays occur in the connection process. This enables faster troubleshooting and gives you access to better insights that help enhance the user experience.
What Is Considered a Good Time to First Byte Value?
According to Google, a good TTFB speed is lower than 200 milliseconds. This number varies depending on the type of information on your page:
- If you are serving static content, TTFB should be less than 100ms.
- For dynamic content, the TTFB should be between 200 and 500 ms.
If the time taken to serve the first byte of content exceeds 500 milliseconds, your users will likely leave your services or applications, and Google will lower the ranking of your website.
What Causes Slow TTFB?
TTFB can be higher for multiple reasons. Issues can occur during any phase of a request’s lifecycle – sending a request, generating a response, and returning the response back to the server.
TTFB measurement starts with the client sending a request to a server. However, the server might not get the request instantly. Factors like the time to complete a DNS lookup, the speed of the user’s connection, the location of the server, and disruptions in the connection influence the time required for a server to receive the request.
After the server receives the request, there are additional aspects that could affect the time required to produce the response, including the time taken to make database calls, execute scripts, and cache response.
Then, the response needs to travel back to the client, just as a request needs to travel to the server. The connection between the client and server has a significant impact on the time required for the response to travel back. For instance, if the client is connected to the server through an unstable Wi-Fi hotspot, the time required for the first byte of the response to reach the client might increase.
In addition to the factors mentioned above, here are additional factors that could show a slow reading of TTFB. These can be something simple like: system resources or environment setup and include:
- Resource (e.g., I/O and memory) unavailability during high web traffic
- The configurations of the servers, such as PHP settings
- Unstructured code
Regardless of what factors caused the high TTFB, you must address them immediately to minimize their impact on page speed and user experience.
How to Measure the Time to First Byte?
You can measure TTFB using different tools. Broadly speaking, they can be categorized into two types – lab tools and field tools.
Lab tools, also called synthetic monitoring tools, report information gathered in a regulated environment with predetermined device and network parameters. They let you simulate the browsing session of your site visitor as if they were accessing the website, for example, from a different part of the world or a variety of devices.
Since they let you conduct consistent simulated tests, they are extremely useful when debugging issues or testing features before deploying to production.
Moreover, they are inexpensive, so you can run multiple lab tools to ascertain your results. Lighthouse, Chrome DevTools, and Sematext Synthetics are some of the most well-known tools.
Field tools, also known as real user monitoring tools, report information gathered from actual site visitors. They work with field data, which is based on real-user visits so it reflects the actual devices, network conditions, and geographic locations of your users.
One of the biggest differences between Field tools and Lab tools is the representation of data.
Because reports generated by field tools are based on data gathered from all users, they show the distribution of real data based using 75th percentile method. Lab tools on the other hand show a single data, which might be a subset of the real data. Google Search Console, Chrome UX Report, and Sematext Experience are just a few examples of such tools.
Depending on your monitoring needs, you can opt for one tool or both. This article on Web Core Vitals testing tools compares all types of solutions to help you pick the right one for your use case.
Recommendations: How to Improve Time to First Byte?
There are several techniques you can apply to improve the Time to First Byte. Here are a few of them.
- Set up a cache layer. Caching means keeping a copy of a site’s resources in a Content Delivery Network (CDN). Once cached, those resources don’t need to be downloaded again from the server, reducing the server overhead and increasing the resource-loading speed.
- Use a good Managed Service Provider (MSP) and a fast host server. Consider using a dedicated hosting provider if you want to avoid slow response times. When choosing your hosting provider, look for providers that offer high availability, enhanced security, and quick and easy support.
- Implement a CDN (content delivery network).CDNs give you access to worldwide servers that can be used to distribute static material more quickly. Whenever a user tries to access a resource, the service that is closest to them will start serving their request, reducing the network latency and improving the user experience.
- Monitor server loads. If the server is too loaded, the resources required to produce a response might be unavailable as a result of which, the TTFB will be affected. To avoid the unavailability of resources, you should monitor the load on the server and implement measures to scale up the resources as the web traffic increases. You could also add a load balancer to cache both static and dynamic content.
Test and Monitor Time to First Byte with Sematext
Sematext Synthetics is a synthetic monitoring tool which you can use to monitor your TTFB for any website. With Synthetics, monitoring TTFB, as well as other important metrics such as Web Core Vitals, is as simple as creating a Browser monitor and pasting in the URL which you want to keep an eye on.
Unlike Chrome DevTools and Lighthouse you can monitor websites from different parts of the world and with the device of your choice, which is useful to know as your TTFB scores in India may vary a lot from your scores in the USA.
You can create multiple monitors from the same page for different locations or devices as shown below:
Once setup (which is as simple as clicking the next button a couple of times) you will get your TTFB scores along with other web vitals charted over time. You can easily track and create alerts for these metrics in case they cross a certain threshold. This way you can have the peace of mind that your website is performing well regardless of your users’ location.
To learn more about Sematext Synthetics, check out the video below or start the 14-day free trial.