TTFB or Time to First Byte is the hardest thing to optimize in WordPress. This guide will help you with implementing some easy steps to improve TTFB.
Table of Contents
- What is TTFB?
- How to Measure TTFB?
- How to Reduce TTFB in WordPress?
What is TTFB?
Time to First Byte. As the name suggests, it’s the time required to receive the first byte from the server, or inessential how fast your receive data when requesting a webpage.
TTFB vs Loading Time
Sometimes TTFB is confused with loading time of a website. However, they’re not the same. Loading time refers to the total time of a request which includes sending, TTFB, downloading, parsing, etc.
How to Measure TTFB?
There are several tools to measure the TTFB. My favourite one is https://tools.keycdn.com/performance because it will do the test from 14 locations.
What is Good TTFB?
Google recommends having a TTFB of maximum 200ms. Even 200-400ms is ok. Anything beyond 500ms is considered slow. It will clearly affect the whole speed of the website and user experience.
How to Reduce TTFB in WordPress?
Use Cloudflare DNS
DNS has a vital role in page speed and TTFB. It is how your browser finds your server and connects to it. Faster your browser connects to the server, faster TTFB!
Here is a comparison on the response time of Cloudflare DNS with popular services:
|Provider||ProvResponse Time (lower is better)|
|Route 53 (AWS)||49 ms|
|Google Cloud||59 ms|
Use a Cache Plugin
For every new request to a page, WordPress has to execute PHP and MySQL queries. But 90% of the time you don’t need it. You can generate HTML files and serve them directly. It’s very fast when compared to generating it from PHP.
There are several plugins that help you to enable cache in WordPress.
My favourite one is WP Rocket.
Use a VPS server or High Performance Managed Hosting
Unlike shared hosting, VPS servers and a few managed hosting providers don’t share resources across other sites. What this means for you is a faster website.
Here are few that I recommend:
Use PHP v7.3
Which version of PHP are you using? Is it 7.0 or 7.1 or 7.2? If so you should definitely upgrade to PHP v7.3.
If caching or static website isn’t a good solution (especially for e-commerce, forums) then speeding up processing the only way. It’s not just about increasing CPU and RAM.
Even though it’s a smaller upgrade in the number, the performance is notably different!
Use TLS 1.3
TLS is the successor of SSL. It’s a protocol to provide end-to-end encryption (HTTPS). TLS 1.3 is the latest version. Version 1.3 reduces the number of round trips and provide a significant improvement in TTFB.
It requires only a few changes in the server, but you could reduce up to 250ms just by upgrading to TLS 1.3.
Choose Server Location Wisely
If your audience is in India and your server is in the US, that will add an extra 200-300 ms network latency.
Use OpenLiteSpeed or LiteSpeed Server
LiteSpeed is a web server similar to Nginx and Apache which provides a much better performance, especially in terms of TTFB. OpenLiteSpeed is the open-source version of LiteSpeed enterprise.
Cache HTML Pages on CDN
An HTML page is the first piece your browser asks when a user visits your website. Due to several factors, Cloudflare by default won’t cache HTML/JSON. However, you can write custom rules to cache HTML pages in their CDN servers. This will decrease the TTFB by 10x or even more!
Use Cloudflare Argo
Argo detect real-time congestion and route web traffic across the fastest and most reliable network pathsCloudflare
Cloudflare powers 10% of the internet! They know which is the fasted path to deliver. With Cloudflare Argo, you can speed up the TTFB by 35%.
Argo isn’t free, unlike the above services. It costs $5.00/month + $0.10 per additional gigabyte.
Convert to Static Website & Use Static Hosting
What is a Static Website?
If your WordPress site not very dynamic, you can create a static version of it. A static version is a site that contains only HTML, CSS, JS, images etc. Not PHP or MySQL. A landing page for a company/product, blogs, etc is good examples of static sites.
What is Static Hosting?
Static hosting providers like Netlify are designed for high-performance delivery of static files. It comes with built-in CDN, including HTML.
Creating Static version of WordPress and deploying
Install WP2Static plugin which will generate the static website. Then connect Netlify as the hosting provider (I’ll write a detailed tutorial for this).
Enjoy super-fast static sites!
The first impression is the best impression. TTFB is more important than your total website load time. I hope the above steps will help you to decrease the TTFB.
Comment below if you’ve any queries or feedback. I read and reply to each of them within 12 hours!