Improve TTFB on WordPress

Hello,
I would like to optimize my WordPress website TTFB on https://mjmetrix.com by using plugins. Unfortunately, the best first byte rate I can get for now is “C”.

:dodgy:

Does someone has some expertise to share about this hard-to-fix issue.

Thanks a lot

When you’re trying to reduce TTFB, the last thing you want is another plugin. There are two main ways to shorten that time: 1) eliminate as many plugins as you can, and 2) get a faster server. Hope that helps.

Isn’t this more a server side issue? If you read the other posts about TTFB and WordPress, it’s more about fine tuning your WordPress backend services like Php, MySQL, server hardware, etc.

I’m not sure if plugins can help you here.

Better hosting (particularly if it uses SSD’s for the database) is probably the best path to actual fast performance. There are some caching plugins that can help hide the actual performance (w3c total cache used to be one of my preferred ones) but it will still be painfully slow on cache misses and the cache performance depends heavily on the hosting provider.

I’ve had almost instant page performance from a WP install on a dedicated host with SSD storage and a memcache-based page and query cache but that takes a lot of work to set up well and can’t be done on a typical shared host.

1 Like

Thanks a lot for your help

Glancing at your WPT report, a good starting point will be for you to run mysqltuner.

Then implement all mysqltuner suggested tunings.

Also, check to make sure you’re using the InnoDB storage engine for all tables, as MyISAM has so many problems there’s been talk about removing MyISAM altogether.
[hr]
I know I’ll likely catch flack for saying this…

You’re using CloudFlare… the source of many problems… all outside your control… which you can never fix…

Also, day to day, sometimes CloudFlare works + sometimes fails either completely or worse… intermittently… which is another source of impossible to debug problems…

First step of dealing with speed issues, for me, is always remove all cruft code between Apache + visitors.

So right now, you’re trying to debug likely CloudFlare injected problems, with no control over CloudFlare.

First step… Remove CloudFlare, which is sufficient to fix many site problems.

@dfavor

Interestingly we are using Cloudflare too. The rationale in using Cloudlflare is to protect the origin server from attacks (as much as where possible), simplify administration e.g. DNS, HTTPS, HTTP/2, etc

If Cloudflare is or can be the issue, what’s the alternative?

What options are there to improve TTFB with Cloudflare (free)?

Even though this is 9 months or so old, probably worth making a few quick points.

Firstly, slow TTFB with WordPress is mostly due to a combination of:

  1. Slow-ish server
  2. Slow theme
  3. Too many (or slow) plugins

The fixes, as mostly listed above are:

  1. Tuning plugins as much as you can - by uninstalling, or through settings
  2. Tune theme, if possible at all
  3. Upgrade to faster hosting

Breaking these down in a little more detail:

1. Tuning Plugins

There are a few plugins that assist with performance tuning. For instance, if it looks like the cause might be slow SQL, there are several plugins that provide EXPLAIN data, such as “Query Monitor”. Install and look for slow queries. If you have access to set up slow query logging with MySQL, also do that. MySQL tuning is a topic in itself, though the most usual causes are lack of indexes or queries which “break” indexing by using the wrong sort of expression in WHERE clauses.

Also, be aware that some plugins execute their code on all pages, regardless; definitely worth checking for. (This is a no-no). There are plugins out there that will assist by switching off this behaviour and you could contact the author/s and nicely beat them around the head until they fix their plugin - it should execute as little as possible on unrelated page and admin hits.

An often used and raved about plugin tuner is P3 Plugin Performance Profiler; I haven’t yet tried it but have heard good things.

2. Tuning theme

Unfortunately this can be harder. The best fix is to switch to a well maintained theme system - if you want something robust and simple Genesis is popular, and also Oxygen is getting more popular these days. If you have heavy performance problems with a theme, it suggests that security and other problems may be coming down the line. If your site is commercial, you’re probably best paying a small amount of money for a commercial theme. Look for large user numbers as that means it will stay supported into the (more) distant future - a common problem is that the authors have moved onto other things in 2-3 years, just when you’ve become reliant on their theme! You want the ability to receive security updates promptly when problems occur, so some care in selecting vendors will help you in the long term.

3. Hosting problems

Firstly, nearly all WordPress websites will benefit from a decent caching system; in general, one can shave seconds just by installing a decent caching system. My two favourites are WP Rocket (commercial) and Litespeed Cache (free, but works best with Litespeed server). If you don’t control the server (eg: cPanel etc, smaller sites) I’d strongly suggest you go with WP Rocket - the money is so worth it - as it produces huge speed leaps out of the box, with no configuration. I’ve seen huge results with WP Rocket nearly every time.

As an aside, while the old favourites are WP Total Cache and Supercache, I find those harder to configure for a great result, and more likely to break sites. Great results are still possible with these guys, and in some cases they’ll be more configurable, but be prepared for a learning curve. If it’s all too much for you, then go the Rocket or Litespeed route for now.

In terms of actual hosting, the ultimate in speed solutions for a WordPress site, other than specialized and often highly customised hosting, is to use a webserver running the Litespeed server, coupled with Litespeed Cache installed as a plugin. Again, this produces great results out of the box, usually with little or no configuration. While cPanel and Litespeed combined are surprisingly good, if your site is under heavy load you’ll probably be better off with a custom VPS as others have said above.

Litespeed server on cPanel is incomparable at this point, for a number of reason. While entirely compatible with Apache, it is a complete drop-in replacement when installed. Apache has a number of profound problems where performance iss required, the top being that it exhibits both memory leaks and exponential dropoff when the load gets high. Speaking as a former hosting company owner/senior admin, I’ve seen performance results for Litespeed that are hard to believe until you see them with your own eyes (2-5x improvement on server load profile, for instance). Nginx gives similar results, but Litespeed works better in a cPanel environment, and is more than sufficient for normal mortals in most cases (ie small-med non-eCommerce sites).

By the way, whatever you use for caching, the idea is that it pre-loads the page for you and stores the result of WordPress execution, generally in a flat file, and just outputs that file directly to the browser on page hits. This will result in an immediate drop in TTFB, as well as an ability to serve more pages at once without slowing down (as it takes less effort to generate those pages). When faced with buggy themes and plugins that are slow, sometimes this just solves so many problems it’s easier to let the caching solution hide the slow plugins from view.

Re plugin selection - when selecting plugins, try not to install plugins with a small user base, especially if it doesn’t look like they’re well documented, or haven’t been updated recently, or have very low star ratings. It’s a bit of an art form, but you should be able to get a sense of whether a plugin is well written from a combination of those things.

Apologies for the poor writing, hope this helps, and that I haven’t left anything crucial out, nor submerged you with too many details.

Stay tuned, hope to have an announcement re performance monitoring with WPT on WordPress soon if all goes well!

2 Likes

You’re loading a lot of cached css files. These do slow TTFB no matter what. Also the DNS+Connect+SSL take up around a second.

Instead of relying on the provider’s settings for redirecting to https, you could set up an .htaccess redirect, which is actually faster.
In fact you can set up one redirect for both https and canonical (e.g. non-www to www or vice-versa) in .htaccess, which usually cuts down the response from around 1 second to under 400ms.

The above solution is a good replacement for having to configure an HSTS policy in the headers (HSTS doesn’t work with redirects in any case), and takes care of the canonical issue, without the need for extra plugins.

Other than that, there’s isn’t much you can do with TTFB since WP, unlike Joomla, lacks its own cache system for the html output from database queries.
There isn’t much that can be done here - this is a matter of server processor and memory. Even if plugins are added to handle html output, they will use server resources so the benefit will be cancelled.

You can either upgrade your hosting to get more server resources. Or you can migrate your website to a CMS like Joomla, where you will no longer need most of the extra plugins (and possibly Cloudflare), will be able to use a robust built-in cache system, and have more server resources available.

You need to TTFB with the popular tools widely used by WordPress experts. The results slightly vary when you compare each testing tool, so this way you can check your TTFB from different angles. You can check more here to fix it: Here's the Guide About How to Reduce TTFB in 5 Easy Ways

I also use Cloudflare on my site. Is Cloudflare the reason behind poor LCP and TBT score on

this page?

I have installed Autoptimize and WP Fastest Cache plugin for performance and caching.

Any help is appreciated.

Thank you.