How to Reduce TTFB in Google Page Speed Insights

Google’s Page Experience algorithm is coming. Are you ready for it? You may have noticed something in Google PageSpeed Insights test by the name ‘Reduce Initial Server Response Time.’

That is what is known as the Time to First Byte or TTFB. If you are seeing this warning again and again, you need to act on it and fix the issue ASAP!

Here is how it looks like:

One of the easiest ways of doing that is to upgrade your server to a more powerful one. You see, the hosting company you choose is the one that will control the server. They get to decide the type of hardware they use.

When I say that you should upgrade to a more powerful server, I simply mean that you should consider moving out of the shared hosting environment and consider alternatives like a VPS hosting, a dedicated hosting, or a cloud VPS or simply cloud hosting.

Yes, I know that moving to a VPS or a dedicated server might not be financially feasible. This is where cloud hosting pitches in with affordable pricing.

Ignore Amazon AWS or Google Cloud Platform as they are quite expensive. Alternatives like DigitalOcean and Vultr will offer you powerful servers for as little as $5 a month

But again, choosing the right cloud hosting server is also important. While SSD storage is one standard feature of cloud hosts, there are companies that offer even better SSDs. For instance, with DigitalOcean, you can get NVMe SSD, and with Vultr, you can get High Frequency Compute Servers.

I will get to hosting later in this article as I gradually reveal how to reduce TTFB. But before I do so, let’s talk a bit about TTFB.

What Should Be the Ideal TTFB?

Start by looking at the table below and you will immediately know what you should try to achieve:

TTFBGood or Bad or Garbage
0 to 200 millisecondsRecommended by Google
200 to 400 millisecondsAverage
400 to 600 millisecondsSlow
800 to 1000 millisecondsBad and unacceptable
1000+ millisecondsGoogle considers your site to be garbage.

So, the ideal TTFB for any WordPress site or just about any site in this world should be within 0 to 200 milliseconds.

If you are using a WordPress site, there are many factors that will determine the TTFB. Hosting you select is of course, one of the most important factors. Of course, you should not forget things like the theme you are using, the plugins that you use, and the myriads of third-party codes that sit on your website.

These third-party codes can include codes and scripts from your ad network like AdSense. It can include Google fonts, Google Analytics code, social media sharing, and more.

There are too many things that collectively define your TTFB or Time to First Byte. So, you need to makes sure that you are optimizing everything.

Check Your TTFB

Before you head over to optimization steps, you need to know the status of your website. Test it with Google PageSpeed Insights and find out. If you don’t see the warning (the first image in this article), your site most-likely passed the audit.

Your site will pass the audit if the initial server response time is below 600 milliseconds. Anything above that will mean that you site failed in that audit and you will see a warning.

If you don’t see the warning, you might see something like this:

Just because your site has a TTFB of below 600 milliseconds, it doesn’t mean that you should stop optimizing. Your objective should be to achieve the TTFB time recommended by Google. You should try to get a score between 0 and 200 milliseconds. If you are outside the Google’s recommended range, you have failed to carry out proper optimizations.

You can also use alternative resources like GTmetrix, Pingdom, KeyCDN tools, etc. for finding out the TTFB.

If you never heard of KeyCDN tools, it allows you to test the performance of your website across different locations at once.

Here is what a test with KeyCDN tools looks like:

With KeyCDN performance test, you may notice that TTFB is different for different locations. That happens because of the distance between the origin server and the testing server. The higher the TTFB for a location, the further is that test location from the origin server.

What’s the way to reduce that distance? The best way is to server your entire website through a CDN. I will get to this later.

Okay, now that you have checked your Time to First Byte, it is time to look into things you can do to reduce TTFB.

Shall we start?

Things You Can Do to Reduce TTFB

Change your hosting company

If you are on a shared hosting server, it is possibly one of the reasons for your high TTFB. Shared hosting providers are infamous for this. Of course, there are some options like GreenGeeks, FastComet, ChemiCloud, etc. that are viable options, I will still recommend you move to cloud hosting.

Yes, handling cloud hosting can be difficult, and hence, I recommend you go for Cloudways – a managed cloud hosting company that gives you different choices. You can select between Google Compute Engine, Amazon AWS, Linode, Vultr, DigitalOcean, etc. All these are big names and offer trustworthy hosting solutions with state-of-the-art infrastructure.

I strongly recommend opting for DigitalOcean of Vultr high frequency compute. The moment you switch hosting and hit the cloud; you will see a significant improvement in your initial server response time.

You need to remember that speed doesn’t come at a low price. If you want quality, you need to pay for it.

What do I use? I use DigitalOcean (direct and not through Cloudways), but currently I am in the process of moving all my projects to Cloudways, specifically on Vultr High Frequency Compute servers.

Yes, it does cost a lot more than what I would normally pay to Vultr if I went to them directly, but do not forget that with Cloudways, you are going to get a managed platform with easy controls.

You don’t have to bang you head when it comes to SSL renewal, server updates, security patches, etc. Cloudways will take care of all those for you, thus allowing you the time you need to focus on your website without worrying about the technical things.

Don’t worry about migration. You can use their free migration tool or request a free migration. However, I do have an upcoming guide on how to move your website to Vultr HF through Cloudways from any other host without losing content, but ensuring that your database is clean!

I, for instance, moved one of my websites to Vultr HF (via Cloudways), and I managed to reduce my database size from 1.8 GB to a mere 22 MB without losing any content whatsoever!

My site is much faster now because of two reasons:

  1. The database is lean and mean.
  2. The server is super-fast.

Here are some of the hosting companies that I will ask you to avoid:

  • HostGator – Very bad support and though they have everything unlimited, nothing is unlimited really. They have severe CPU limitations.
  • GoDaddy – Though their servers are fast enough, they particularly infamous for allowing malware hosting.
  • Hostinger – Very disappointing. You can go for it only for starter sites and static sites.
  • WP Engine – Horrible site speed. They have become a dinosaur. When they first came into existence, they were good, but not any longer.

There are many more!

Plugin Watch

Just because a plugin exists and promises to do great things, it doesn’t mean that the plugin is good. Some plugins are terribly coded and consume a lot of CPU. Such plugins can slow down your website terribly.

One easy to find out a slow plugin is to install another plugin called Query Monitor. Install and activate it. Then load any page on your website. Go to Query Monitor tab and then to Queries >> Queries by Component.

This is where you will see which plugin takes how much time!

You will be surprised to know that Yoast SEO is one of those plugins that slow down your website, and so does WooCommerce, Backup Buddy, Beaver Builder, AddThis, and more!

In case you don’t wan to use a plugin, you can install a Google Chrome extension called WP Hive. Once you install the extension, visit the WP plugin repository and open a plugin page. WP Hive will show you the problems.

Here is a result for Yoast SEO:

Worried which SEO plugin to use? SEOPress will be a good one. But if you already have Yoast on a large site will hundreds of posts, I will not recommend making a switch.

WordPress Heartbeat

Okay, this is a very critical thing. WordPress Heartbeat is an ajax call that uses admin-ajax.php. Plugins and themes that use API use the Heartbeat will stop working if you disable the Heartbeat function.

Unfortunately, Heartbeat can slowdown your website (not necessarily) at times. Only way to find that out is to go through GTmetrix waterfall chart and check the results. You can use other such testing tools.

Some people will ask you to completely disable this. Well, you can do that if you are certain that none of the plugins and themes you are using are using the function.

Once you are certain that none of the plugins and themes are using the Heartbeat API, you can disable it. Make sure that you check your website thoroughly after you disable it.

There are some plugins that can help you disable Heartbeat. For instance, WP Rocket caching plugin can do that for you, and so can LiteSpeed Cache.

Alternatively, you can just add a small code to your functions.php file. If you don’t want to add code manually to the functions.php file, you can use a tiny plugin called Code Snippets and the code through it.

Here is the code:

add_action( ‘init’, ‘stop_heartbeat’, 1 );
function stop_heartbeat() {
wp_deregister_script(‘heartbeat’);
}

If you are adding the code to the functions.php file, you need to add it right after the <?php tag.

Combine CSS and JS

This is also a grey area. What you should do will depend on various things. For instance, if you are combining all CSS files and the eventual combined CSS file is more than 60 KB, you will be better off by not combining them. The same goes for JavaScript files as well.

Also, combining can help to speed up your website if you are using HTTP/1 protocol. With HTTP/2, you don’t have to combine, because HTTP/2 is far more efficient and can load multiple files at once.

I said that this is a grey area. For some people combining CSS and JS files can help to improve TTFB data, for others it does the opposite. So, test things properly.

Forget Page Builders

Okay, you must have heard the names like Divi Builder, Elementor, and what not! They advertise themselves a lot and say that you don’t need to know coding, and that you can use a drag-and-drop interface to create amazing page layouts and so on!

Well, they are right!

But what they don’t tell you is that they use countless div wrappers, CSS and JS files that add bloat and significantly slow down your website. In fact, the websites using page builders are always the worst-performing websites when it comes to speed.

Even worse, when you remove any page builder for redesigning your site, the builder leaves behind codes – bloated codes that are difficult to remove. You need to manually look for orphaned codes on every page and post to ensure that such codes are eliminated.

If you want to use a page builder, use WordPress’ default editor – the Gutenberg! It is a block editor that will allow you to create different layouts!

PLEASE DO NOT USE PAGE BUILDERS. THEY SUCK! THEY WILL ______ UP YOUR SITE! GOOGLE WILL HATE YOUR SITE!

Choose Your Theme Wisely

Yes, your theme plays a vital role! A terribly coded theme can cause high CPU usage. Use a very well-coded theme. My favorite is GeneratePress, but it is not the only theme you can trust. There are several more. You can go for Astra, OceanWP, Oxygen, Hello, etc.

CDN Please

Do you remember I said that if the origin server is far from the test server, the TTFB will increase? It is true not just for testing, but also for real-world scenarios. The farther away a visitor from your server location, the greater the Time to First Byte or TTFB.

So technically, you can reduce the TTFB, if you serve your website from a server located close to the visitor. You can do this with FSD cache or full site cache. You can use Cloudflare to do that and set a page rule as shown in the image below:

The asterisk you see after the URL’s trailing slash is the wildcard which says that if any URL is starting with factslegend.org/, the undermentioned caching rules will apply. Since every page on my site starts with factslegend.org/, the entire site gets cached.

Once you set the rule, hit the Save and Deploy button, clear Cloudflare cache, and you are done! Now, Cloudflare will cache your entire site and store it in all its CDN servers globally. Your site will reach closer to your visitor! This will significantly reduce the TTFB.

If something is not right, consider removing your site from Cloudflare and setting it up from scratch. Even better, you should consider using Cloudflare’s Automatic Platform Optimization plugin when you setup Cloudflare from scratch.

Do not forget that the CDN can sometimes negatively impact your site. So, proper configuration is extremely important.

Also, if your site only caters to local visitors, never use a CDN!

Use the Right Cache Plugin

Your caching plugin always plays a vital role. You need to find the caching plugin that can not only perform the basic function of caching your site, but also eliminate the need for using extra plugins by adding several important functions in a single package.

For instance, LiteSpeed Cache and WP Rocket, both offer image optimization, Heartbeat control, DNS prefetch, localization of certain resources like Google Analytics, etc.

I personally use LiteSpeed Cache, but you are free to use WP Rocket. Both are equally good. In case you don’t want to use any, you can always go for options like WP Fastest Cache or, WP Super Cache (you will need several extra plugins for both) or, or W3 Total Cache (one or two extra plugins will be required).

Configuring your caching plugin correctly is a must. Wrong caching configuration can slow down your website and throw errors! Click on the links for the caching plugins above and read about the proper settings.

Get Rid of Things You are Not Using

Are there themes and plugins on your site that you are not using? Remove them completely. Just deactivating them is not helpful.

Unused or deactivated themes and plugins store a lot of data in your database, making your database slow. Remove them all! Just keep the default theme. You will need it for troubleshooting if something someday goes wrong.

Clean Your Database

Database queries happen in split seconds, but when your database has unnecessary data, it does eat up some time to return the results. So, it is necessary that you clean up your database and remove things that are not necessary. This will speed up your site.

Caching plugins like WP Rocket, LiteSpeed Cache, WP Fastest Cache, W3 Total Cache, WP-Optimize, etc. have built-in database cleaning features.

The cleanup features are quite rudimentary for some plugins, and they can remove only a few unused data like expired transients, spam and deleted comments, trashed posts and post revisions, etc.

If you need advanced cleaning where you can go through tables used by removed or deactivated and deleted plugins, you should use WP-Optimize. It does a great job, in identifying the plugins and themes that have left behind some data in the database even after you have removed them.

Do not forget to backup your database and website before you perform the cleanup. If anything goes wrong, you can use the backup to get your website back.

Optimize Third-Party Codes

Third-party codes contain a lot of things including Google Analytics, Google Fonts, Google Tag Manager, Facebook Pixels, and more! You need to optimize them properly.

First thing first, don’t use Google fonts, and if you are using Google fonts, make sure you are localizing them and calling them through CSS. That sounds nerdy, right? Forget that! Use the plugin called OMGF (Optimize My Google Fonts). It will localize the fonts for your and serve them locally from your server.

For other things like Facebook Pixels or Google Analytics, I will suggest that you use some plugin to localize them. There is OMGA or Optimize My Google Analytics by the same developer who created OMGF. Alternatively, you can use LiteSpeed Cache or WP Rocket to localize Google Analytics.

The optimization part is very difficult, because most of the times you will not know what to do. Trust me, the biggest culprits are always Google fonts and Google Analytics. If you are using Google tag manager, you should localize that as well.

Talking of ads, especially Google AdSense, this thing is going to mess up your website’s speed. You may replace the word ‘mess’ with a word of your choice.

Way around? Use Cloudflare’s Rocket Loader. Enable it from Cloudflare account. You need a premium account for this.

If you are using some other ad network, Rocket Loader might not be able to help you. For instance, if you are using Mediavine, their ads are totally not compatible with Rocket Loader. However, they do lazy load their ads. I don’t know about other ad networks.

PHP 7.3 or Higher

As of today, almost every web hosting company offers PHP 7.3 as the default PHP version. However, you can always use 7.4, which is the most stable and fastest latest version you can work with.

Do not using 8.0 because that is still not a stable version. PHP 7.4 can make your site a tad faster, and trust me, every millisecond counts.

However, if you are using PHP 7.4, do not forget to test compatibility with plugins and themes. If there are issues, roll back to 7.3.

Premium DNS? May Be!

Sometimes, DNS lookup can take a lot of time. This usually happens if you are purchasing domain from cheap providers like GoDaddy or Namecheap. If is fine to purchase from them, but if they have the option of upgrading to Premium DNS, do that! I know Namecheap offers premium DNS.

Prefetch External Resources

Your site will have third-party codes that load from servers other than your server. This takes extra DNS lookup time. You should consider prefetching them (make them load before they are requested). Caching plugins like WP Rocket, LiteSpeed Cache, etc. have this prefetch option. If your caching plugin doesn’t have the option, consider changing your caching plugin. You may even think of using Perfmatters, which allows DNS prefetch.

Conclusion

Reducing TTFB or Time to First Byte is not an impossible task. Yes, it may be difficult, but with a little bit of determination, you can do it! There are certain laborious things you need to do, but they are total worth your time and money. After all, a fast website can get in good books of Google, which in turn means better rankings, and hence, increased revenue.

Scroll to Top