How To Reduce Server Response Time (TTFB) 14 Terrific Ways

If your site is taking more than 3 seconds to load, then there is a problem, and you need to fix it as quickly as possible. According to research, more than 53% of people leave the site if it takes more than 3 seconds.

So, you need a faster web host and a lighter theme to solve this problem. If you have both and still facing this issue, then here are some pro tips from my side that can definitely help you to decrease server response time (TTFB).

1: Reduce CPU Load

This is the most trusted way to reduce the TTFB or Server Response time. Most web developers would suggest this point to you.

CPU usage restrictions are popular in WordPress websites. They become more prevalent when you use shared hosting because shared hosting doesn’t have too many resources. However, this problem can also occur in a good hosting plan. When that occurs, it instantly slows down your website as there are no resources left to serve content to your website.

CPU usage difficulties can lead you to not only bad user experience but can immediately impact your website ranking in Google Search Results.

Here are some quick tips that may help to reduce CPU usage:

(A) Quickly Remove Unnecessary Plugins

Plugins are important for WordPress users. Plugins make our site engaging, but these plugins can also affect our site performance in a negative way. If the plugin is way too heavy, it’ll consume too many resources which will significantly decrease our site speed.

It’s really important to choose lightweight plugins, especially, if you’re using shared hosting. I’ve published a post in which I’ve discussed how to detect slow plugins. This article will help you find slow plugins, click here to read.

(B) Optimize Images/Serve Scaled Images

When a page or post loads, it loads various types of elements including images. The problems occur when an image loads because its metadata also loads. However, the metadata doesn’t help you in any way. So, it’s important to remove metadata from images. Removing metadata will boost your site speed.

To optimize or serve scaled images, you can use the plugin called Ewww image optimizer, it’s a great plugin that offers various features for free. It can help you compress images by 80%

I’ve published a post in which I’ve shown how to use Ewww perfectly to get the best result. Click here to read!

(C) Update Plugins And Themes

Plugin and themes are quite helpful in WordPress to complete the required setting without getting help from Developers. It is crucial to update the Plugins and defeat its bug and other problems that lead to future problems. Also, make sure you’re downloading plugins and themes from trusted users.

(D) Update WordPress Version

You should have the WordPress version up to date. WordPress developers constantly release updated WordPress versions to solve the bug reported in their earlier versions. The new version will come with high-level security, the most advanced feature, and faster speed.

2: Limit Bad Crawls

Crawling is really important, it helps to index your site in search results, however, not every crawler is useful. In fact, most crawlers that you see on your site are waste, they provide unnecessary pressure to your server, which results in a slow site.

There are a few ways that can help you remove or limit those bad crawls. The most trusted plugin that can help to block bad crawl is Wordfence.

Use the “crawl rate-limiting rules” feature in Wordfence to assure that a useful bot does crawl. Also, you can adjust settings for crawlers giving that your website doesn’t get hindered due to random CPU usage. You can also prevent IP addresses if you believe someone is constantly hitting your servers for no reason. This will enhance the experience of real visitors and improve site performance in all scenarios.

3: Enable WordPress Caching

Caching is a must to improve your site performance. You should be using some sort of caching on your site. Caching not only helps to improve site speed but also increases user experience, which can result in high revenue.

According to Amazon AWS,

A cache is a speedy data storage layer that reserves a subset of data, normally temporary in nature so that later calls for that data are served up quicker than is possible by entering the data’s original storage location. Caching enables you to efficiently reuse earlier retrieved data. The data in a cache is usually stored in fast access hardware like RAM and may also be practiced in association with a software component. A cache’s main purpose is to improve data retrieval performance by decreasing the need to reach the underlying slower storage layer.

How To Enable Caching

There are two ways to enable caching, one is by the plugin and one by using CDN.

Once you are connected to your site with Cloudflare CDN or any other CDN, you won’t need to enable caching because it will be already enabled.

The plugin method is also very simple. I suggest you use the W3 Total Cache plugin as it has all the features you need to boost your site speed. I’ve published a post in which I’ve discussed how to set up W3 Total Cache.

Result With Caching Disabled

Result With Caching Enabled

As you can see, the page size is almost similar but there is a big difference in load time. The load time with caching disabled was more than 1 second which is not that bad but it is slow. On the other hand, when I enabled the caching, the load time was around 800 ms which is fast.

So, now make sure to enable caching as it serves your site faster and reduced the load time.

4: Upgrade Your Hosting Plan (Avoid Shared Hosting)

Shared hosting may be a good option if you’re just starting out, but once your site begins to get some traffic, you should consider upgrading shared hosting to Cloud or VPS.

You might be wondering why I don’t suggest shared hosting to anyone. The reason is simple, with shared hosting, you’re sharing your server with multiple sites that means, if one site gets a sudden traffic spike, it may affect your site as well. Now, to get more info about shared hosting we should look at some Advantages and Disadvantages of Shared Hosting.

Benefits of Shared Hosting Plans

  • (A) The most obvious benefit of choosing shared hosting is its price. Shared hosting can cost you between 3$ to 15$ a month depending on the brand you’re choosing. (Shared hosting plan by Hostgator will cost you around 7$ a month, but SiteGround shared hosting on other hand will charge around 15$ a month.)
  • (B) Your host will take care of the administration and maintenance of the server that means you don’t need to worry about technical issues of the server.
  • (C) You’ll get cPanel or other user-friendly applications that are created to make website management effortless.
  • (D) You get many email accounts at your own domain as well as the benefit to have more than one database.
  • (E) Shared hosting offers MySQL and PHP support.
  • (F) Although a number of sites share the same server, most shared hosting plans provide for around-the-clock supervision, maintenance, and technical assistance that provides you uptime security almost similar to dedicated plans.

Drawbacks Of Shared Hosting

(A) One of the biggest issues with shared hosting is their security. Shared servers are normally inclined to hacking attacks. Any malicious action that the server experiences influence the whole network of websites using the server.

(B) Server response time or TTFB is generally poor. Shared hosting loads slowly compare to Cloud or VPS. As you require to share the resources of a server, your site may oftentimes encounter sluggishness brought about by the demand for resources by other websites.

(C) You may undergo resource restrictions as everybody else in the system uses the same CPU, memory, and hard drive.

(D) Server may get swamped by requests or burdened which might cause it to freeze.

(E) Your hosting plan might have lesser features compared to VPS or Cloud hosting plans.

(F) You do not have the option over the software and app that you need to use as you cannot use any additional software apart from what is given by the hosting provider.

5: Enable/Use GZIP Compression

Gzip compression helps to compress files like HTML, CSS, JavaScript, and more. When a user asks for a page from your site, the algorithm transfers the output back in a compressed form. Depending on data size, the compression can decrease file sizes by up to 40% to 70% which is very effective in reducing your page size and making your site faster.

GZIP Compression feature is available in almost every speed booster plugin. I suggest you use either W3 Total Cache or WP Super Cache.

6: Connect Your Site To A CDN

There are numerous CDN sites available on the internet but not every CDN is good. You may have heard about Cloudfare before, it’s a free CDN that has over 190 servers across the world.

Cloudflare is good and free, so, if you’re a beginner, you must try it once. However, Cloudflare receives criticism for its response time, some people even say their site is loading slowly after connecting it to Cloudflare, and that is why I don’t really suggest them much. The fastest CDN that you can find today is BunnyCDN.

Connecting to BunnyCDN is fairly easy, but the problem is it isn’t free, you have to pay as per your usage. Btw, I’m not an affiliate of BunnyCDN, in fact, it doesn’t have an affiliate program, I’m suggesting it simply because of the praises it receives for its speed.

Also, you can do your own research, there are hundreds of articles available on the internet about the pros and cons of both Cloudflare and BunnyCDN.

Now, we’ll look at how you can connect your site to BunnyCDN and Cloudflare, however, you must know how a CDN helps to reduce the server response time and makes your site faster.

How A CDN Helps To Reduce Server Response Time

According to Cloudflare, CDNs increase the speed of sites by caching content in various locations around the globe. CDN caching servers are normally found closer to end-users than the host server. Requests for content travel to a CDN server instead of all the way to the hosting server, which may be thousands of kilometers and across many autonomous networks from the user. Cloudflare says, using a CDN can massively decrease page load times.

Let’s take an example to understand it better. Suppose a visitor from Brazil is trying to access your site, but your site’s server is located in the USA, then the request that the Brazilian visitor is making will go all the way from Brazil to the USA which would increase the latency rate, resulting in a slow site. If you’re using a CDN, then the request that Braiallian visitor is making will go to the nearest server present in Brazil, which would certainly increase the site loading time.

How To Connect Your SIte To Cloudflare

Connecting a site to Cloudflare is simple however, you do need to pay a little bit of attention because it requires some sort of website knowledge. You can connect to Cloudflare by using their plugin, but I’m gonna show you the manual method because I think that’ll be more suitable for you.

  • Step 1: Go To Cloudflare’s Site

Go to Cloudflare.com and create your account, it’ll be free. Enter your email address and put a strong password.

  • Step 2: Select Infrastructure Program
Account Cloudflare Web Performance Security
  • Step 3: Add Your Site (Enter Your Site Name)
Account Cloudflare Web Performance Security 1
  • Step 4: Now Choose The Plan

Cloudflare provides 4 types of programs, 3 are paid and one is free. For this post, I am taking the free one.

guidemewp.com Account Cloudflare Web Performance Security

Snap-on Continue after selecting the plan.

  • Step 5: Now Cloudflare Will Check Your Site’s DNS

Cloudflare will show you your site’s records. It might confuse beginners. Now click on the Continue button once everything fully loads.

guidemewp.com Account Cloudflare Web Performance Security 1
  • Step 6: Change Your Site’s NameServers

This is the most significant step to connect Cloudflare. You have to edit your site’s current name servers with Cloudflare’s nameservers.

Copy Cloudflare’s both the nameservers and paste them in notes.

guidemewp.com Account Cloudflare Web Performance Security 2
  • Step 7: Log Into Your Domain Registrar Account (I’m using Godaddy)
  • Sign Into Your Domain Registrar Account
  • Click On DNS

For this post, I am using the GoDaddy domain.

Once you are in, scroll down and you’ll see the “DNS” option, click on it.

Godaddy Setting DNS
  • Click On Change (Change Nameservers)

Your current nameservers will be visible under Nameservers, click on “Change” to replace them with Cloudflare’s nameservers.

Godaddy nameservers change 2
  • Step 8: Paste Cloudflare’s Nameservers

Please paste the nameservers you copied.

Cloudflare nameservers

Click on Save to keep the settings.

  • Step 9: Click On Confirm Nameservers

Now, go back to Cloudflare and click on “Confirm Nameservers”. It may take up to 24hrs to propagate, but normally, it propagates within one or two hours.

  • Step 10: Review Cloudflare’s Success Message
guidemewp.com Account Cloudflare Web Performance Security 3

How To Connect Your Site With BunnyCDN

As I said earlier, BunnyCDN is faster and reliable than Cloudflare. However, it is a paid CDN which means you can not use it without spending money even if your site is new. But, BunnyCDN is really cheap as it only charges you as per your site’s traffic.

Note: You can only use one CDN for your site. So, if you’re already using Cloudflare that means you can’t use BunnyCDN, and vice versa.

  • Step 1: Go To BunnyCDN’sSite And Create Your Account

Click on “Try FREE For 14 Days to go to the signup page”.

Bunny CDN Setup
  • Step 2: Fill Up Login Info

Put your email and set up a solid password. Also, check T&C.

Bunny CDN Setup 2
  • Step 3: Check Your Email

Bunny CDN will send you a mail to your email to confirm your account. Click on “Confirm Account”

Confirm your bunny.net account
  • Step 4: Add Pull Zone Set Up

Create it’s time to set up Pull Zone.

  • Fill in your site’s name (Just enter name, no extensions like .com or .net)
  • Enter your original URL (example, hostinggrow.com)
Add Pull Zone bunny.net
  • Step 5: Copy Your Bunny CDN URL

A page will present to you where your Bunny CDN URL will be noticeable. Scroll down and copy it.

Pull Zone Installation Instructions bunny.net
  • Step 6: In BunnyCDN, Click on purge pull zone

Go to BunnyCDN and click on Purge Pull Zone.

Purge Pull Zone In BunnyCDN

Check CDN Status

Go to Gtmatrix.com or any other speed checker tool and check your website’s overall speed performance. Scroll down a bit and notice the CDN color signal, it should be green (green indicates that your site is now connected to a CDN).

7: Enable HTTP/3 In Cloudflare

According to Cloudflare, One of the main praised advantages of HTTP/3 is increased performance, especially around fetching multiple objects simultaneously.

In addition, HTTP/3 allows 0-RTT support, which means that subsequent connections can light up much faster by reducing the TLS response from the server when setting up the connection. This indicates the client can start requesting data much quicker than with a full TLS negotiation, meaning the website begins loading earlier.

How To Enable HTTP/3

  • Go to Cloudflare Dashboard

Log in to your Cloudflare account, select the domain, and visit the dashboard.

  • Click on “Network”
  • Turn On HTTP/3

That’s it!

8: Don’t Allow Data Sharing In Plugins

Plugins collect data to improve quality, however, the problem is it increases CPU usage which can significantly affect your site speed.

Next time whenever you see a pop or option to allow data sharing, don’t allow or enable it.

9: Disable/Limit WordPress Heartbeat API

WordPress heartbeat API does more bad than good. This feature shows real-time plugin notifications, but it consumes too much server resources which increases the server response time.

There are two ways to completely stop or limit WordPress Heartbeat. We can use a plugin called LiteSpeed cache or add a code in a PHP file.

Plugin Method:

LiteSpeed Cache has so many options to make your website super fast, but the point that makes it different than others is its WordPress Heartbeat option.

With a few steps, you can adjust the Heartbeat API.

  • Install & Activate The Plugin
  • Open on LiteSpeed Cache and then Click on Toolbox

Once the installation is done, click on LiteSpeed Cache and then select Toolbox to find the Heartbeat API option.

LiteSpeed cache settings
  • Click On Heartbeat
LiteSpeed cache toolbox
  • Turn On Frontend Heartbeat Control

You can adjust the heartbeat intervals to reduce server utilization with the help of the Frontend Heartbeat TTL option. Recommended setting 60 seconds.

  • Turn On Backend Heartbeat Control

Let Backend Heartbeat TTL as default (60 seconds)

  • Turn On Editor Heartbeat

Note: Turning on this function will affect the WordPress autosave feature negatively.

Let Backend Editor TTL as default (15 seconds)

WordPress Heartbeat API Settings
  • Click On Save

Don’t forget to click on the Save button to save the changes you have made.

Manual Method:

To completely stop the heartbeat API, add the below code in the “functions.php” file of your theme.

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

Warning!

If you are thinking to stop WordPress API completely, then you should think again. Without the WordPress Heartbeat API, all the corrections you made in the post will be lost if you ever forget to tick the Save Draft key. And you will no longer have access to the revisions

10: Upgrade The PHP Version

The latest PHP version is 8.0 but only 0.7% of people are actually running their site on PHP version 8.0. However, according to WordPress, the suggested PHP version is 7.4 or greater. You don’t need to worry too much if your site is not working on version 8.0, version 7.4 is enough to do the job for you.

If your site is running on a version less than 7.3 then you must consider upgrading it as soon as possible. Older PHP versions not only make your site slow but also invite risks of hacking and malware.

How To Upgrade PHP Version

I’ve published a post in which I’ve covered almost every popular host. It is a step-by-step guide, read it now!

11: Clean WordPress Database

Cleaning up the WordPress database becomes important in the order to enhance the site’s speed. Sadly, not many people take it seriously.

If you’ve never cleaned the database, then it’s the right time to do it.

It is really easy, there are many plugins available in the plugins section of WordPress that can clean the database for you for free.

The most trusted plugin is by far Wp-Optimize.

How To Clean Database With the Help of WP-Optimize:

  1. Install Wp-Optimize
  2. Go to Optimizations
  3. Select everything except Auto drafts and Remove unapproved comments
  4. Click on Run All Selected Optimizations
  5. Go to tables and clean tables as well
  6. Schedule Optimization.

Read How To Clean WordPress Database In Detail

12: Use Cloudflare’s APO

Cloudflare Automatic Platform Optimization (APO) for WordPress is an optimization service that effectively distributes your WordPress site’s HTML and third-party fonts over Cloudflare’s globally-replicating Operators KV database and edge network in 200 centers worldwide.

Cloudflare tested this feature on 500 sites and found on average, it decreased TTFB by 90ms. However, this feature isn’t free. it would cost you around $5/month but worth testing if you have a slow TTFB. Make sure it’s compatible with your caching plugin.

Test Results (Credit: Cloudflare)

MetricPercentilesBaseline CloudflareAPO EnabledImprovement (%)
Time to First Byte (TTFB)90th1252 ms351 ms71.96%
10th254 ms261 ms-2.76%
First Contentful Paint
(FCP)
90th2655 ms2056 ms22.55%
10th894 ms783 ms12.46%
Speed Index
(SI)
90th6428558613.11%
10th130112424.52%

13: Limit Post Revisions And Autosaves

WordPress gives revision control on any pages/posts that you create which enables you to go back and view previous edits that you’ve made over in your database. While this can look like an excellent thing to have, over time it can drive a lot of needless burden in your WordPress database.

For example let’s assume that you’ve previewed a post or page that you’ve been working on 7 or so times, For all of those revisions you might have just edited around a word or two or made some really least modifications. However, in the WP database, you would now own 8 copies of your first post, the 1 main one, and 7 revisions storing the entire content of that past revision and not just the modifications made since the last one.

How to Limit WordPress Revision

Applying the following steps below I’ll show you how you can restrict the number of revisions that WordPress will save per post or page. By default, there is no end on the number of revisions so any limit you force is going to help keep your WordPress database more useful. We will be doing the WP_POST_REVISIONS setting in our wp-config.php file to achieve this.

In this case, we are going to fix our max number of revisions per page or post to 3. So in total, there will be four records in the database per post or page, 1 for the original itself, and then the 3 newest revisions. In this example, I simply began a new post with the name Test, and then in the content of the post I simply started in Test #1 and then previewed the page, then I started Test #2 and previewed the page over up until I got to Test #7.

  • Login to cPanel.
  • Go to the cPanel File Manager Code Editor and open your wp-config.php file.
  • Put in the following code towards the top of the wp-config.php 
Copydefine('WP_POST_REVISIONS', 3);
  • After that hit on Save Changes at the top-right.

14 Disable WordPress Cron & Replace It With Real Cron Jobs

Cron is a Unix/Linux service that is normally used to schedule commands or a script on a server that works in the background. A cron job is a job itself, which is used to program tasks at periodic fixed times, intervals, or dates. Typically these include repeated tasks that are automated to save your time. In WordPress, this is controlled by WP-Cron, that is used to simulate a system cron.

Some examples of a WordPress cron job may include scheduling a post to publish or a backup plugin working on a predetermined schedule.

Disable WordPress Cron

If you want to disable the WP-Cron, then simply add the following code to your wp-config.php file, before the line “That’s all, stop editing! Happy blogging.” Reminder: This disables it from working on page load, not when you ask it directly via wp-cron.php.

define('DISABLE_WP_CRON', true);

Create Cron Job in cPanel

If you are using a host with cPanel, you can also build a custom cron from their control panel. Note: make sure you stop or disable the default WP-Cron first.

Step 1: Log in to cPanel. In the Advanced section, click on Cron Jobs.

Step 2: Under the Add New Cron Job section, you can choose from a number of different pre-defined schedules, such as twice per hour or once per week. Your hosting provider most likely has a limit on how often they allow cron jobs to be run. Twice per hour is a common setting for shared hosts.

Step 3: Add the following command. Replace https://domain.com with your domain name. This command might vary slightly based on how your hosting is configured. Then click on “Add New Cron Job.”

The >/dev/null 2>&1 part of the command above disables email notifications.

Check your TTFB (Server Response Time)

Once you perform most of the tips mentioned above, you can use some online tools to check how much time your server is now taking. The tool that I prefer the most is GTmetrix, however, you can also use KeyCDN, Pingdom, DevTools, and any other online tools to get the details.

My results:

GTmetrix is showing my site TTFB (Server response time) around 135ms which is absolutely terrific!

Thanks For Reading!

Sumit
Sumit

Sumit is a regular contributor to Hostinggrow.com. He has 6 years of experience in blogging, and he loves football, his favorite player is - Lionel Messi (GOAT), but he has no hate for Ronaldo.

Articles: 54

Leave a Reply

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