fbpx

Understanding Your Website Loading Speed: Time to First Byte (TTFB)

When it comes to solving the problems of a slow website, there are useful measures to determine causes and solutions. One of the more important parameters is Time To First Byte (TTFB).

Understanding the TTFB can help you better understand how your website speed works, what slows your site down and how to fix it.

What is the time for the first byte (TTFB)?

The TTFB is used by all site performance benchmarking tools, and is an important measure of the speed at which your website begins to upload to a specific location or with a particular combination of configurations.

TTFB measures the time elapsed between when a web user makes an HTTP request, such as loading a web page, and when the customer’s browser receives the first byte of information.

Many use this reading as a rudimentary way to test the speed of the server, and although this works, it is really only half the story.

If the website you are trying to load uses a Content Management System (CMS) such as WordPress, the server must perform all the CMS calculations necessary to produce and show the content.

The PHP service must load its MySQL database, get the content, calculate the appropriate HTML output and return it to the website visitor.

If you have a slow CMS, all these steps can take time and you may have poor TTFB results of 1 to 3 seconds or more.

That doesn’t necessarily mean your hosting server is slow or has problems. Most of the time, it means that you have too many add-ons or extensions, that you are not using a caching system or that you are using an older version of PHP.

Of course, it’s a totally different story if you’re measuring a static HTML page with a slow TTFB. So, you may want to investigate from the server itself, as there are no other factors that affect the performance of the site.

The most common solution to decrease the TTFB is to implement a cache system.

How does dynamic caching affect TTFB?

Dynamic caching is like making a waiter at a bar you frequent remember your usual order instead of having to repeat it every time. Because they already know your drink, they can start preparing it as soon as you come in and they serve it to you much faster.

Caching works in a similar way, storing the information needed to serve a web page next time.

Some hosting providers use systems in which, for example, all the computing of the PHP and MySQL services is stored in the RAM of the server.

When a visitor receives a cached response, it is as if they are loading a static HTML page, but faster. It’s faster because the content is served from memory and not from the server’s hard drive. Although SSDs are super fast, nothing compares to server RAM when it comes to speed.

Can all pages be cached?

Not all pages can be completely cached. Verification pages, shopping carts, and registered users have special circumstances. This does not mean that TTFB has to be slow.

If you are using WordPress, the first step is to make sure you are using the latest stable version of PHP.

The you should check how many plugins you are using and how much delay do they cause in the process of loading your page.

Caching tends to camouflage badly built websites by masking development problems. If your site loads quickly without cache, it means it has good code and is “in good shape”. You shouldn’t just rely on Dynamic Caching or its own caching add-ons to have a fast website.

But, what if you have Dynamic Cache enabled and you still have slow TTFB?

Well, there are two things you need to check:

  • Measure the cached result. The easiest way to verify it is to test more than once. It’s normal to get a slower first result and much faster consecutive results. By performing multiple tests, you can guarantee that you are measuring the results in cache.
  • Check from a nearby geographic location. If you’re testing from a remote location, it’s normal to have high network latency. If you want your site to be fast from a variety of locations, consider implementing a CDN.

How does a Content Delivery Network (CDN) affect TTFB?

As mentioned above, the TTFB is seriously affected by the speed of the network between the server and your browser (or the tool you are using to test the speed).

Using a CDN can improve the speed of your site if you have endpoints near your geographic location. However, keep in mind that if you have a CDN, such as CloudFlare enabled, you are measuring the TTFB between your browser and the endpoint of the particular CDN serving your request.

If the CDN has not yet cached your content, you must first call the server, get the data, distribute it, and then deliver it to the client. This can cause an additional delay before the first byte is received.

To fix this, make sure you have caching enabled for your CDN and check to see if you have an endpoint near your geographic destination. It’s worth experimenting with different CDN providers in case your visitors are in a part of the world not covered by the current one.

This is a pretty technical subject, but the loading speed of a website is crucial for many businesses. If you need help with your website, don’t hesitate to contact us and we will be pleased to assit you on any related matter.



Leave a Reply