TTFB stands for “Time To First Byte,” or the timespan from the moment of sending an HTTP request from the browser to the server to the moment that the browser receives the first data bytes from the server. While measuring this timespan, the system also counts the required time for DNS Lookup and network delays. TTFB is one of the essential aspects of assessing website function and optimization. If this timespan decreases, the user access to the resources and webpage load time will increase.

The TTFB consists of three distinct elements:

  • HTTP Request Time: When opening a website on a browser, the browser sends an HTTP Request to the server. The following factors affect the timespan during which the request passes:
    • The DNS Lookup timespan,
    • The geographical distance between the user and the server,
    • The firewalls with complicated rules in between the user and the server,
    • The user’s internet speed.
  • Request Processing Time: As the server receives the user request, it begins to implement the process and retrieves a suitable response. The following factors affect the request processing time and response retrieving:
    • The time required to recall the database,
    • Not using Caching mechanisms,
    • The used code or model is not optimized.
  • HTTP Response Time: After creating the responses, the server will retrieve them to the user. The user and the server internet speed are factors that affect the time during which the browser receives the response.

According to the points mentioned earlier, we can say that the most common factors that have an impact on increasing the TTFB value are the followings:

  • Content-type (static or dynamic),
  • Network-related problems (low bandwidth, geographical distance, firewalls with complicated rules, so on),
  • Weak web server configuration (lacking optimized codes and models, not using the caching mechanisms, so on),
  • Weak server resources (RAM, CPU, disk I/O),
  • Weak database design/configuration.

The Average Timespan for TTFB

Depending on the content type (static or dynamic) and the server configuration, the TTFB value may differ. Therefore, determining the exact TTFB value as an ideal timespan is a difficult task and depends on the condition.

However, you can determine a relative average. For example, if the TTFB is under 100 milliseconds, it is in an excellent condition; if the TTFB is between 200 to 500 milliseconds, it is the ordinary and standard condition; and, if the TTFB is over 500 milliseconds to one second, it indicates that there is a problem to be troubleshot.

As mentioned earlier, the values are relative averages, and you cannot expand them to every website. Depending on the content type and the website complexity, the value that you have obtained for the TTFB may be over one second; however, considering the condition, it may not be unordinary and nonstandard.

How to Measure the TTFB

  • Using Google Chrome DevTools

To use this tool, complete the following steps:

  • Open the Chrome browser on the Windows operating system and press Ctrl+Shift+I or Cmd+Opt+I on the MacOS,
  • On the open window, click on the Network tab,
  • Click on the file on the All section,
  • Go to the Timing section to view the TTFB value.

Hint: Be noted that while using this tool on a PC, parameters such as the bandwidth amount or using a VPN during testing has an impact on the TTFB value measured for this tool. Therefore, if you intend to obtain a more exact value for the TTFB, you’d better employ one of the following methods:

  • Using WebPageTest

Visit the WebPageTest website and define the URL and the desired geolocation to obtain the TTFB value. According to the website guide, they also consider the DNS Lookup timespan and SSL negotiation to measure the TTFB value. Insert the URL and wait until the test ends, then complete the following steps:

  • On the open window, click on the Performance Results section,
  • The number under the First Byte phrase is the TTFB value.
  • Using Pingdom

You can also employ this website to measure the TTFB value by determining a URL and geolocation. Be noted that the website uses the Wait Time phrase instead of TTFB to measure it. When the test ends, complete the following steps to view the value:

  • go to the File Request section,
  • Hold the mouse on your file on the right menu.
  • Using GTmetrix

There is another website to measure the TTFB value named GTmetrix. Here, similar to that of Pingdom, TTFB is called Wait Time. Follow these steps to view your TTFB:

  • Insert the URL,
  • Wait until the test ends,
  • On the open window, go to the Waterfall section,
  • Hold the mouse on your file.

How to Optimize the TTFB Value

You should seek some approaches for optimizing the TTFB value because it has a direct impact on the user experience as well as the website ranking. The following factors can optimize the TTFB value:

  • Using a CDN: A Content Delivery Network (CDN) caches the website content on its edge servers distributed across the world, so it responds to the users’ requests from the geographically closest point. Therefore, the latency caused by the geographical distance between the user and the central server decreases.
  • Codes and Resource Optimization: Using compression techniques, supporting HTTP/2, and employing the caching mechanisms contribute to decreasing the file size as well as optimizing the website function.
  • Database Query Optimization: Create some indexes to correct data recovery only if required. Hence, when recalling, there would be no need to recall the entire database to respond to the received query. On the other hand, not using interdependent subqueries is recommended because it may result in increasing the queries process time.
  • Reducing HTTP Request: First, check the number of HTTP requests. If they are numerous, do the following steps:
  • Remove the website unnecessary images,
  • Reduce the remaining photo sizes,
  • Combine the CSS files.

This way, you can decrease the number of these requests.

  • Ensuring the Fast Server Responsiveness: It is sometimes possible to put the CSS and JS files into the HTML file. The advantage is that there would be no necessity to recall these resources separately.
  • Using the Respond First, Process Later (RFPL) Cache Method: According to this method, the server retrieves a pre-cached response to the users’ requests and processes the received request simultaneously. Therefore, the user accesses the cached content immediately and views a response that does not have a noticeable difference with the server’s new response.
  • Continuous Updating: Make sure of updating server-side parameters to the final version. They can be parameters such as the webserver (Apache, Nginx), the server-side language (Ruby, PHP, and …), and whatever relevant to the server-side.
  • Continual Checking of Logs: You can immediately become aware of the increasing overload of the database web server by checking the logs continuously. When transferring traffic to the server increases, it may not be able to manage the load; therefore, the TTFB value increases.