Time to first byte (TTFB) is a value in microseconds measured from the moment the query is sent until the user receives the first byte of data sent by the server. Unfortunately, this parameter is one of the most popular ways to measure page loading speed. Why unfortunately?
What was the TTFB parameter supposed to be?
In principle, the speed testing methods are to help locate and improve the bottleneck that extends the waiting time for the service. TTFB is just a raw variable, the sum of many other variables. It does not take into account many important parameters and does not allow to determine which exact components translate into an increase in the final result.
What does the tester say about TTFB?
Some tests (such as Google Page Speed Insight, GTmetrix) say “to Reduce initial server response time”. This is quite misleading information, suggesting that the problem is with the hosting machine. Upon closer analysis, you can see that the server’s response includes, among other things, the execution of a PHP script and database queries. In the case of a poorly optimized website, processing a script or executing a complex query to the database may even increase the waiting time for the first byte several times – after all, the data must be processed on the server side before sending.
What does the term “Reduce initial server response time” means?
The GTmetrix guide (https://gtmetrix.com/reduce-initial-server-response-time.html) clearly describes: There are multiple strategies to improve your server response times. Some of the key ones are:
1) Optimizing your application code (including database queries)
2) Implementing server-side caching
3) Upgrading server hardware for more CPU or memory resources
You can clearly see that “Reduce initial server response time” mainly concerns programming parameters:
- slow application development logic (i.e. in practice a poorly designed / optimized application),
- slow database queries (e.g. queries without indexes, or very complicated database queries),
- slow routing (it’s about routing in the application – in practice, a badly designed application),
- frameworks (i.e. code execution overhead, resource-consuming frameworks on which the website is built),
- libraries (i.e. code overhead, resource-consuming libraries that may be unnecessarily loaded),
- Implementation of the cache in the application,
- insufficient processor resources (this is a server-related parameter – most often, however, given directly in hosting packages),
- insufficient memory resources (this is a server-related parameter – most often, however, given directly in hosting packages).
Take into all of the above parameters to improve the “server response time”.
How does TTFB compare to page download speed?
It is also worth noting that the speed of receiving the first byte, and the entire content of the page, is two, not necessarily related values. In a test by Cloudflare (the full test can be viewed here: https://blog.cloudflare.com/ttfb-time-to-first-byte-considered-meaningles/), the compressed page downloaded 5 times faster, even though the upload its first byte took 8 times longer than when the content was uncompressed.
Additional parameters influencing the TTFB
When performing a test using one of the websites available on the Internet, we obtain the TTFB value measured between the server of this testing website and the server on which the tested website is located. Most of the servers offering TTFB tests are located outside Poland or even Europe. Due to the fact that physical location and distance is a very important factor in this type of research (delays on international and transcontinental lines), the obtained result may not give us the complete data that we would expect, because having a Polish website for the Polish users is more we are interested in loading time in Poland than e.g. Of the United States.
Is TTFB useful?
Considering these and other factors not mentioned here, such as DNS server response time, it can be concluded that TTFB is not an appropriate way to measure server performance, but rather a way to measure the performance and optimization of a website. From the user’s point of view, the time to load the entire page is more important than receiving the first byte, so optimizing your page for TTFB does not always have a positive effect on the performance of the entire page. It is worth looking for other, more reliable methods of testing web applications and focus primarily on optimizing the code (eg php) as well as the number and “weight” of SQL queries.
- Does php 8.3 is faster than other versions? - September 18, 2024
- Site infection – first remedial steps - August 22, 2024
- DMARC – changing configuration - December 6, 2023