Time to first byte (TTFB) is a metric for determining the responsiveness of a web server. It measures the amount of time between creating a connection to the server and downloading the contents of a web page.
Connecting to a web server is a multi-step process where each step can potentially lead to delays. When a website is slow or unresponsive, being able to pinpoint the source of the slowdown is key to improving the user experience.
TTFB helps enterprises identify weak points in the connection process. By determining where delays occur, enterprises can tweak their services to perform faster and more reliably. Since a website’s speed can impact its web search rankings, TTFB has become crucial to optimizing performance and increasing visibility.
TTFB is impacted by three key actions: 1) sending a request from a client machine to the server, 2) processing that request on the server and generating a response, and 3) sending the response from the server to the client.
Measuring TTFB begins with the request. The time it takes for a server to receive a request can vary based on the time it takes to perform a DNS lookup, the speed of the user’s network, the distance to the server, and any interruptions in the connection. Enterprises have no control over the link between the user and the Internet, but any delays will still impact their TTFB.
Once a server receives a request, it has to generate a response. This involves starting processes, making database calls, running web scripts and communicating with other systems on the network. Common strategies used by enterprises to reduce TTFB include caching web pages, optimizing server-side code, and improving hardware resources.
Once a server generates a response, it needs to transmit it back to the user. This step is dependent on both the enterprise’s connection speed and the user’s connection speed. The TTFB is determined the moment the client begins receiving the response, literally when the client receives the first byte. Transmitting a request and a response over a network can account for almost 40% of the TTFB.
As part of their website optimization project, spy camera store My-Spycam sought to reduce their TTFB from over 4 seconds to 2. Their strategy involved separating the areas of a page that changed on a per-user basis, while caching everything else on a CDN. My-Spycam modified Magento, their underlying eCommerce platform, to cache everything except for specific pages and page contents (such as a user’s shopping cart).
By adding dynamic caching, My-Spycam reduced their TTFB from 1162ms to 152ms. This strategy of “hole-punching” content on a cached page resulted in dynamic pages that load faster than static pages, without impacting the user experience.
Optimizing TTFB benefits both users and content providers.
The time it takes to load a web page has an enormous impact on customer retention. When 40% of users abandon a website that takes more than 3 seconds to load, having a low TTFB becomes essential. It not only reduces the chance of losing a customer, but ensures users have a fast and engaging online experience.