Reduce Server Response Time - TTFB

How to Reduce Server Response Time (TTFB) of Your WordPress Site?

A slow WordPress website is a headache. Right?

Even after implementing other optimization tips, your site might still feel sluggish if the server is responding slowly to each request. If that is the reason, you will also get a warning in Google PageSpeed Insights.

Multiple factors can contribute to such a slow down. However, do not fret.

In this post, I am going to show you how I managed to reduce the server response time of this website to below 200ms.

Server Response Time - Time To First Byte Test
TTFB of this site according to GTMetrix.com – 190ms – not bad

Before that, let us see what the term server response time means.

What is Server Response Time?

In short, it is the time taken by the server to send the first OK response data (status code: 200) back to the requesting browser.

Time To First Byte (TTFB) is only another term that denotes the same idea.

After your browser sends a request to access a web page, several things happen behind the scenes before it receives a response from the server.

Remember, we are talking about the first response, not the whole page load.

The following are the factors that contribute to the total TTFB in milliseconds:

  • DNS Lookup – When the browser requests a domain, it sends a request to the appropriate Nameserver to find the IP of your domain.
  • Connection Speed – After finding the IP address, the browser then connects to your site’s server.
  • SSL handshake speed – If your site is on HTTPS (it should be), then the browser has to perform an SSL handshake with the server. This ensures that data transfer is secure and encrypted.
  • Wait & receive time – Now the server has to process the request to generate a response. Then send it back to the browser. In the case of WordPress, the WP system generates a response by executing PHP scripts and database queries.

TTFB is the first item that adds up to your overall page loading time. So, even if you use a lightweight theme, fewer plugins, and optimize images, a high TTFB can pose as a performance bottleneck.

How to check TTFB?

For a quick TTFB test, I’ve found the following two tools to be quite useful:

  1. Sucuri Tester
  2. BitCatcha

Both of these sites allow testing from multiple locations and present the results on a single page.

Reduce Server Response Time
Performance Test by Sucuri

On the other hand, if you want detailed reports, GTMetrix or Pingdom can give you a time-wise breakdown of all requests in the form of waterfall charts.

When you hover over the first item on the chart, you can see the times taken by each process before responding. It is helpful in finding the real cause of the delay.

Checking TTFB with GTMetrix
Checking TTFB with GTMetrix

However, you should also keep in mind that there is a bit of inconsistency in the results produced by such tools. So test multiple times from multiple locations before getting to a conclusion.

It is also a good idea to test a simple HTML page with no other external resources before testing your WordPress site. This will help to figure out if the problem is with your WordPress or the server configuration.

What is the ideal response time?

Now you might be thinking, how many milliseconds is a good response time?

It is 2019, and websites are striving to load under 1 second. So, TTFB above half a second is sluggish.

The Google PageSpeed Insights would throw a warning if the response took longer than 200ms. Yes, this is often hard to achieve, but not impossible with proper optimization.

I have tested this website multiple times using different tools mentioned below. By applying the measures written below, I could bring it under the 200ms mark. However, getting it consistently from multiple locations is a challenge.

On average, you should try to keep response time under 500ms. Below 200ms is ideal.

12 Ways to reduce the server response time

These are my suggestions for a better TTFB or faster server response time.

1. Use a Good Hosting

You cannot expect an excellent performance from a mediocre hosting provider. Can you?

Shared hosting with overloaded servers generally gives poor performance.

The good news is, quality hosting does not necessarily mean it is expensive. With a cloud-based hosting provider like Cloudways, you can easily host your WordPress website on DigitalOcean or Amazon, even if you are not technically inclined.

Apart from it, several server management platforms allow you to manage your cloud servers independently.

So far, I have good experience with Cloudways+DigitalOcean combo.

However, if you are starting or have only a few visitors, a shared hosting package will be the most economical option.

From my personal experience, GoDaddy’s shared plans give decent speed.

Check out Hosting Facts for detailed speed test results and uptime reviews of popular shared web hosts.

2. Choose a closer location – Reduce Network Latency

If most of your visitors are from the Americas, it may not be a good idea to choose a server in the Asia-Pacific region, and vice-versa.

Let’s talk some Physics here.

Data transmission on the internet occurs mainly through optical fibers or cables. So the signal travels in the form of electromagnetic waves at a speed of approximately 200k Kilometers per second (slightly less than the speed of light).

So if the server is located halfway around the globe from your visitor, the data needs to travel almost 40,000 kilometers to and fro. That itself will take 200ms of time. It is called network latency.

It is also why my site hosted on DigitalOcean Singapore loads faster from India whereas it appears slower from Europe and the US.

On the contrary, Bluehost – a host recommended by WordPress – appears slower from Asia as their server location is in the US.

When buying a hosting, check where their data centers are located, and choose the one closest to where your audience comes from.

3. Use a CDN

Integrating a CDN (Content Delivery Network) is a great way to reduce latency of static assets like images, CSS, and JS files. It helps to make your site load faster for your users.

A CDN has multiple servers around the globe. They cache the static assets and content (like images) from your site’s origin server. So when a user tries to visit your website, the CDN serves these assets from its own server closest to the user.

Another advantage of using a CDN is the reduced load and bandwidth usage on your origin server. Lesser load means better performance.

Cloudflare, AWS CloudFront, DigitalOcean Spaces, etc. are some of the CDNs you can try for WordPress.

BunnyCDN (review) is another great option to consider especially if you are on a budget.

Remember, CDNs usually do not cache the HTML document. So, it is not a replacement for choosing a closer hosting server location.

4. Use a Caching Plugin

Behind the scenes, the complex WordPress system executes tons of PHP scripts and MySQL queries to generate the content of a page dynamically.

Without Caching, WordPress needs to run all these things for each visitor. If the page content doesn’t change often, it is a wastage of server resources.

On the other hand, caching helps to store the response from the first visit and serves it to the subsequent visitors to that page. This eliminates the need to execute resource-intensive operations.

WP Super Cache and WP Fastest Cache are two free caching plugins that have worked great for me and are easy to set up. W3TC too is good, but it is suited for advanced users.

If you want a premium plugin, WP Rocket is a solid option with some great reviews. However, as I haven’t tried it, I can’t comment about its performance.

Apart from these, if you are on Cloudways hosting, they provide another caching plugin called Breeze Cache, which integrates well with their platform.

Most plugins have the option to purge cache when you update a page. It ensures that your cache is not serving outdated content.

5. Optimize HTML Code

The weight of the HTML response can also affect the load time. If it is huge, TTFB slows down. You can look at the HTML of a page on Chrome by right-clicking and selecting View Source.

Important things to optimize the HTML are:

  • Minification – Minified HTML does not contain unnecessary white spaces and other characters thereby reducing the file size
  • Removing unwanted codes like WP Emoji
  • Concatenating multiple resource files (CSS & JS) into one file

Plugins like W3TC, Breeze Cache and WP Rocket do all these for you.

Also, take care to use a lightweight theme like Astra if possible. Performance-optimized themes usually contain less code bloat.

6. Enable GZIP

GZIP is a type of compression that helps to reduce the size of HTML document by up to 85%.

Almost all good web hosts support GZIP. To ensure it:

  • Open your site in Chrome browser
  • Go to Networks Tab and reload the page
  • Then click on the first response (document) to reveal the details.
  • If you see content-encoding: gzip under Response Headers, you are good to go. Otherwise, ask your hosting provider about enabling it.
Verifying GZIP in Google Chrome
Verifying GZIP in Google Chrome

7. Reduce Redirects

Suppose your site’s address is https://www.example.com. If you use links inconsistently across your pages like http://example.com, the browser has to send more requests to reach the final URL (accompanied with 301 status codes). This further delays the response.

  • Use a consistent URL scheme for internal page links – with or without http:// & www
  • Ensure both mobile and desktop versions of the site uses the same address. Avoid using a separate mobile site like mobile.yoursite.com or yoursite.com?mobile=1. Instead, use responsive design.
  • Set your preferred domain in Google Search Console so that the search engine only index the correct version of your site.

8. Improve DNS lookup speed

DNS (Domain Name System) lookup is the first thing that happens when someone enters a domain name into the browser’s address bar.

Usually, the default nameservers that come with your domain registrars are slow.

SolveDNS helps you to find out the DNS speed of your website’s Nameserver.

Currently, I use Cloudflare to resolve the DNS for this website. And I have found that it is a lot faster than the default GoDaddy Nameservers.

If you don’t need Cloudflare’s CDN feature, you can turn it off and use only the DNS feature.

9. Check for SSL Speed

SSL or HTTPS is an essential security practice and you cannot avoid it. While testing your website speed on Pingdom, find out what time it takes for SSL handshake.

If you are on shared hosting and your SSL is slow, ask your hosting providers for ways to improve the SSL speed.

10. Use Updated Server Software

Using outdated server software can be another reason for slow performance. So it emphasizes the need for selecting a reputed WordPress hosting provider.

If you are managing your own server, make sure that you use the latest versions of Apache or NGINX.

11. Use PHP 7

According to a performance test by GeekFlare, PHP 7 is two times faster than its previous version – PHP5.6.

It is the latest branch of the popular server-side programming language, and it is way more efficient.

So while shopping for a hosting provider, ensure that they provide PHP 7.

12. Upgrade Server Hardware

Lastly, if you have done all the things to boost the response time and still your server responds slowly, then it may be time to upgrade your hosting.

An underpowered server cannot handle a website with a massive amount of traffic. You should be happy about it because your site has become popular and successful.

Check the RAM size, CPU cores, and bandwidth limits of your current server. If that is the limiting factor, upgrade it. Or if you are on a shared plan, it may be time to move to a VPS or cloud hosting.

Conclusion

Reducing TTFB is only the first step in speeding up a website. There are several other things to do including image optimization and enabling browser caching.

If I have missed any important point, feel free to mention it in the comments.

Leave a Comment

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

Scroll to Top