There are so many reasons why a website could be slow, and one reason is TTFB, or Time to First Byte. Most of the WordPress optimization tips focus on the front-end of the website, tips like compressing your images or minimizing CSS.
While these are good tips for speeding up your website, you mustn’t neglect the backend either otherwise you will have slow database queries, your origin server getting to its limit because the code is not being executed efficiently, and so on.
What is TTFB?
TTFB stands for Time to First Byte and it describes how long it is from when a visitor puts in an HTTP request to when the first data byte is received from the web server. There are three components to this:
- The time that is needed for sending the HTTP request
- The time that is needed for the server to process it
- The time that is needed for the first byte to be sent back from the server
How Slow TTFB Negatively Affects Your Visitors
The web browser is provided with an HTML file which contains the asset references; each of these assets must then be downloaded in sequence. The browser doesn’t even begin to download without being in receipt of the HTML file but, as they start to receive the first bytes of that file, they will begin downloading the assets.
So, you can see from this that the TTFB has got a good deal of importance. However, in many cases, some website content may be blocked from fetching the assets until the HTML has finished downloading.
Why Could Time to First and Time to Last Byte be Slow?
The best way to find out if your website backend is slow is to run a speed test using a tool like KeyCDN or Pingdom. This will show you how long the time to first byte is, giving you a starting point for fixing the issues.
On average, you want to be looking for a TTFB time of less than 100ms; between 200 and 500ms is a standard speed, 500ms to 1s is not good and anything above 1s needs fixing.
It is critical that these issues are quickly identified because fixing them can have a significant impact on the way your architecture has been built or in the design of your database. Any asset that follows will be affected by the delays.
The following is a list of some of the more common issues:
- The code that is on the origin server is not efficient
- Design of your database may result in slow queries, such as commits, indexes and stored procedures, etc.
- The web server has not been configured correctly
- The origin server is at full capacity
KeyCDN has produced a web performance tool that will test your TTFB on one asset from 14 separate test locations. All you need to do is input the asset URL and you will be given a report on the status of that asset, the cache status, DNS, ETag, TLS, and TTFB.
If you see a green indicator, it means the time is under 400ms; this is the ideal test to tell you which locations are returning a slow TTFB performance.
One other metric to consider is TTLB – Time to Last Byte which, as you would expect, is the time taken to deliver the final byte of data.
If there are significant differences between TTFB and TTLB, it could be down to general connection issues or geographical locations, leading to an increase in latency and a decrease in speed and throughput. Identifying both times is recommended so that you can see where the issues are occurring and fix them.