How to reduce Time to First Byte (TTFB)?

For anyone, a fast website makes a noticeable difference. Even search engines like Google and Bing appreciate faster websites compared to the slower ones. But when it comes to rankings, yes a fast website makes a small difference.

Note that engaging content is still a ranking factor, just fast site speed will never going to help you rank unless the keyword is very very easy to rank.

In technical terms, Time to First Byte, in short TTFB is a measurement used as an indication of the responsiveness of the web servers and network resources.

TTFB is a duration from the user making an HTTP request to the first byte of a page being received by the user’s browser. Short time means a fast loading website while more time will result in multiplying slowing effects.

First Byte
GET request made – request ACKnowledged – waiting – finally First Byte or TTFB!

Look at the image, I have loaded my subscribe page while using the DevTools.

DevTools: Waterfall
DevTools: Waterfall

In the image, we can see the subscribe document started receiving its content in 47 ms, while most of the visible content (images, styles, scripts, etc.) loaded in 132 ms. Some deferred and non-visible resources loaded just after some milliseconds – 337 ms. This shows how fast is a website.

Note that each and every millisecond matter here, because initial load time will decide how fast the rest of the content will load.

Can we reduce the TTFB?

Yes, there are few ways we can make it super fast, but that will come with the cost of using some extra tech. But the best thing is a few of them can be achieved for free while some of them are affordable these days.

  1. Use the fastest domain name system service. Cloudflare is the fastest one.
  2. Switch to a faster host. Avoid shared and cheaper servers.
  3. Make use of fast and latest web server applications. PHP7 and Nginx.
  4. Make use of caching wherever needed. FastCGI is the most reliable one.
  5. Take advantage of CDN efficiently for global delivery.

1. Use the fastest DNS service.

The domain name system resolver resolved the domain name and IP address. Every server has at least one IP address like 192.168.0.1 which is not fancy at all and only useful to machines. So we use the domain names which are easy to remember and to resolve it we need a domain name system service.

Many domain registrars offer a domain management dashboard. It helps to manage the domains to propagate, resolves, and handle all the modifications in the records. But they could be slow and frequent changes will take you to a long route because they are slow and not utilizing modern routing techniques.

There are many Free and Paid DNS services like Amazon Route 53, GoDaddy Premium DNS, Google Cloud DNS, and Cloudflare.

We suggest Cloudflare DNS over any slow one because it is free and the fastest one in the industry. Look at the worldwide availability of their presence, they are almost everywhere and they are increasing their availability all the way.

Cloudflare Network Map
Cloudflare Network Map

To use Cloudflare DNS services all you need to do is, point the name servers to Cloudflare and add all the DNS entries and DO NOT ENABLE the cloud icon. Allow the changes to propagate. Once everything is running on Cloudflare DNS you will see a slight improvement in DNS.

According to DNSPerf, these are the list of all well known DNS service.

DNSPerf

2. Switch to a faster host.

You may never know but your web hosting server may slow your website down to a larger extent. If you are using a shared hosting service to host a busy site then chances are high that you are already in the slowest bullock cart.

Usually, shared servers suffer from a high latency because of busy neighbors and usages of heavy software like cPanel and WHM to control the users.

Shared servers that use cPanel is already using outdated software because of which you’ll never experience the advantages of the latest software.

For an instance take PHP 7, it was launched on 15th December 2015, which was known for its tremendous improvements in performance and stability, but it took over 3 years for the shared hosting companies to adopt it.

I blame cPanel and WHM for this because they do not update packages unless they feel their customers are going to switch to other alternatives.

Similarly, the Apache webserver is still the first choice for shared and managed servers which are known for the OHKAY-Ohkay performance in the industry.

Nginx and OpenLiteSpeed are the newer and fastest ones. I personally do not use Apache because that will be like using an abacus instead of a calculator.

Hardware-wise cheap hosting companies do not use SSD or NVMe drives to enhance the system responsiveness. If you are planning to host a blog, eCommerce site, forum, or massive website use an SSD drive at least.

3. Make use of fast and new web server.

Once you decide to buy a decent web hosting server, make sure you use it with all the latest apps. If you can manage your server yourself, better avoid the installation of cPanel or similar dashboard based software.

You can take advantage of the Nginx server with FastCGI cache to eliminate any concurrent load on the server. Nginx can handle static content very well.

Similarly, you can make use of the latest PHP 7.4 version.

PHP 7 came with many noticeable improvements and now it has been upgraded to 7.4 which took everything to the fastest performance we can achieve in the same hardware resources. Look at the image to understand the difference.

PHP Performance
Requests per second on various PHP versions, higher is better.

Before installing the latest PHP version make sure your site is compatible with it.

WordPress in its official documentation said that they are supporting the latest version of PHP and in the coming days they will drop the support for outdated versions. So just make sure the theme and plugins are upgraded recently.

4. Make use of caching wherever needed.

WordPress is a dynamic CMS we all know that, if you are using it as a blog or website then caching will eliminate the need of generating static versions of the same web page again and again. Cached contents can be served faster because it is already available in memory or cache to download.

Available caching options with WordPress:

  • FastCGI Cache, a server-level cache (Nginx) [Recommended]
  • WP Super Cache, easiest one (WP Plugin) [Recommended]
  • W3 Total Cache, not recommended to smaller sites (WP Plugin)
  • Cloudflare, only for 100% static websites (Full Page Proxy Cache)

From the above options, you can use anyone based on your setup. If you are using Nginx better use FastCGI cache which will eliminate the need for a cache plugin. Since it is a server-side cache it is the fastest and more efficient one.

You can serve the cache directly from the server memory, which means the network will be the next limit.

If you want to use a plugin-based caching option then use WP Super Cache or W3 Total Cache is always there, I’ll recommend only WP Super Cache here.

Cloudflare can be used as page caching using full page cache, but only recommended when a website is purely static and the content will never change.

The limitation is you need to manually purge the cache from Cloudflare if you made any minor changes in WordPress.

Note that Cloudflare’s full page cache won’t work well with blogs and forums, it is only useful when you have a static website. Let’s say you made a website with WordPress and nothing is going to change, use full page cache offered by Cloudflare. It will be the fastest setup anyone can achieve.

5. Take advantage of CDN for global content delivery.

Now we come to a different case where we want to serve the website to the world. Here we can use CDN (Content Delivery Network) to deliver the static contents very quickly by delivering the static resources to the user from his nearest available PoP (Point of Presence) CDN servers.

CDN

It is a really challenging job to sustain TTFB for web pages, but we can improve the loading speed of static resources by hosting them close to users.

This is where CDN comes in. A CDN service can have as many as PoP (Point of Presence) possible. But more presence means addition in the monthly fees. So choose wisely.

BunnyCDN
BunnyCDN Network Map

I recommend starting with BunnyCDN (ref link), as they’ve decent availability in the world by placing their network presence in the most strategic places while maintaining the lowest cost which makes it an affordable to use CDN service.

This is all, as of now we have the above technology to improve our website’s TTFB. In the coming days, we will see HTTP/3 and QUIC which is about making a certificate secured connection (HTTPS connection) faster.

Please raise a comment if you are confused, have any query, or feedback for us.

Leave a Reply

Your email address will not be published. Required fields are marked *

Responses

  1. Logan Avatar
    Logan

    Useful article. I was aware of the TTFB term in SEO articles. But never knew the importance of it and ways to achieve that.

    Recently I upgraded my server from PHP 5.6 to 7.4 and performance improvement was noticeable. It seems as fast as locally hosted. I’m definitely going to try out DNS and CDN stuff to take it to the next level. Thanks.

    1. AtulHost Avatar

      Glad to know that this article helped you in some way. Stay tuned for more server improvement tutorials.

  2. Rijhu Sinha Avatar
    Rijhu Sinha

    Hello Atul Sir,

    This is really very informative and useful post. Thanks for sharing such a complete article on how to reduce time to first byte (TTFB). Well I am aware to these words but do not have such an in-depth knowledge. Thanks for making my concepts so clear. And after going through your article I am very sure this will definitely be very useful for the newbie bloggers too. Thanks for your research and sharing this with us. Please do keep sharing more similar and informative articles.

    Thanks & Regards,
    -Rijhu.

  3. Shamshul Azam Avatar
    Shamshul Azam

    It is good detailed post and I am using cloudflare and it is very good and reduced the page load time upto 60%

  4. Jess Avatar
    Jess

    Switching to Cloudflare DNS was an immediate improvement. I can feel the responsiveness in the domain name resolutions.

    I checked my PHP version, my hosting service recently upgraded to PHP 7, and the latest version of WordPress 5.5 is flying on it.

    But my host is still on max PHP 7.2 while you said the latest one is 7.4. Isn’t there any way I can try the latest one?

    1. AtulHost Avatar

      Hi Jess, first of all, thanks for sharing your experience with us. I’m glad to know that you cared about TTFB that is neglected by many webmasters. Many hosting companies recently adopted the latest PHP 7 upgrade, but few of them are actually on the latest version. You can contact your hosting company about that, they’ll definitely help you out.

      Since you’re already on PHP 7.2 I don’t think there will be much difference in upgrading to PHP 7.4. Just make sure nothing is outdated.

  5. Anatoly Avatar
    Anatoly

    It was a resourceful read for me. I read your FastCGI server-side cache solution too, it worked very well to me and I thankful of you making that tutorial very easy to understand. I appreciate you man.

    1. AtulHost Avatar

      Thanks for the kind words.

  6. Jon Avatar
    Jon

    Hi AtulHost,

    Thanks for this detailed article, I’m impressed with the all possible solutions you’ve explained in detail.

    1. Atul Kumar Pandey Avatar

      Thanks for the feedback Jon. Stay tuned for more updates like this.