Ultimate Guide to WordPress Performance

Let’s make WordPress faaaaaast. We’ll start simple, and then move to optimizations most articles don’t talk about. Studies have shown each second can change your conversion rate by 7%.


The Basics

These are some big wins that are must-haves for any website.

Install a caching plugin

There are lots of good ones. The simplest one is called Breeze. Going up in complexity a little there is WP Rocket and WP Super Cache with WP Rocket being a paid plugin. I haven’t used WP Super Cache much, but WP Rocket is great at being a sturdy plugin that doesn’t have many bugs, and although they’re not the quickest to adapt new features, they are reliable. However, speed-wise, you’ll still get as good of performance from WP Super Cache for free. Moving on in complexity, there is W3 Total Cache and Swift Performance with Swift Performance costing money. W3 Total Cache is a jumble of all sorts of options. It has never felt that user friendly, but if you know what you are doing, and like wading through a lot of options, W3 Total cache looks powerful. Swift Performance is a plugin I recently found out about that has a lot of additional features that the other plugins don’t have, such as a nice interface for preventing plugins from unnecessarily loading on pages, and a good built in image optimizer. However, I do feel like the focus on all of those features might mean a single feature might not always work perfectly, and it takes a lot of time to go through all of the options after which you may not have any speed improvement over the easier to use plugins. Or you might be slightly faster. But in general, all of these plugins will produce similar results, and it doesn’t matter all that much which one you use, just use one! They’ll improve the speed of your site tremendously.

Optimize Images

You want an image optimizer that does three things: downsizes images, compresses them, and serves them in a webp format where appropriate. To be friendly CDNs, pages should be delivered with img tags turned into picture elements that contain the webp tag. I have found webp express to be a fantastic plugin that does all of this. Before WebP express was around, I used Ewww Image Optimizer or WPMU’s Smush.

Use a CDN

This will cause your website to be loaded from a server close to your user. This is especially good for international users. There are 2 types of CDNs. CDNs like CloudFlare will proxy all traffic through them so they can perform additional processing and security rules. While this does provide a very quick way to speed up any site, theoritically you’re going to be a little faster if you don’t spend time being proxied through someone like CloudFlare (unless, perhaps, if you’re paying for CloudFlare’s Argo product, or you’re on a super expensive plan with them). The other type of CDN simply stores files without all of the extra overhead. I use StackPath, but any CDN will do.

Have a good Host

Make sure you’re using a fast webhost like Cloudways or wp-overwatch.com. On WP Overwatch’s upper plans they will do all of these performance optimizations for you.


Server-side Improvements (ie how to know if your webhost is good)

These are the items you will want to look for when finding a good webhost. Remeber, just because a hosting company is popular, that doesn’t mean they are fast. Bigger hosting companies are often slower to implement new features.

Server-side caching

There are two common server-side caching mechanisms. Varnish and LiteCache. You will want to use these in addition to your caching plugin. Caching plugins will perform optimizations such as minification, that server-side caching programs do not do. Server-side caching programs have a super-fast in-memory cache. So the best solution is to use both a WordPress caching plugin, and use a webhost that supports server-side caching. Note that there is some additional setup to make sure the server-side cache is flushed each time your WordPress caching plugin flushes its cache. The Breeze plugin will auto-detect if Varnish is installed, and WP-Rocket has a checkbox that can be checked if Varnish is installed. Also note that LiteSpeed is an alternative to Apache. LiteCache runs on LiteSpeed servers (there is also an open source version of LiteCache for Apache). Not all LiteSpeed servers come with LiteCache, so if you see a webhost advertising LiteSpeed support, make sure they also support LiteCache.

HTTP/2

Released in 2015, HTTP/2 is a must have. It is faster in many ways. Make sure your webhost supports this.

Railgun

Cloudflare offers a service called Railgun, but this has to be installed by your webhost to work. Your webhost also needs to be a partner of Cloudflare. Railgun speeds up communication between your server and Cloudflare’s servers by only sending data that has changed since the last time your website was loaded.

PHP 7+ or HHVM

The difference between PHP 7 and the previous version is incredible. (they skipped version 6, so the previous version is version 5.x.) Before PHP 7 came out Facebook created their own optimized version of PHP called HHVM which is also fast. Make sure your webhost is using PHP 7 or HHVM.

IOPS

Most web-hosts advertise the fact that they are using SSD drives, but then they limit your IO speed. This is fine as you don’t want someone else on the server maxing out the hard-drive, but the true metric you want to look for is the IOPS benchmark. IOPS stands for “Input/output operations per second”. The next best metric is the read/write MB/s speed, but this measures the read/write speed of sequential data which is not that representative of what the hard-drive does when it loads a website. Either way the point is don’t get fooled into thinking that an SSD drive is something wonderful to have on a hosting plan, unless you’re using a dedicated server.

Memory

Server-side caching uses a lot of memory, so you will need a web-host that isn’t frisky on how much memory you get. You will want a minimum of half a GB, and ideally you will want a full GB. If you often have more than 5 users loading your site at once, you may need more memory. Solutions like New Relic can monitor how close you are getting to maxing out your memory.

Up-to-date MySQL/MariaDB

You’ll want to make sure your webhost frequently updates MySQL as updates come out. MySQL updates will often include performance improvements. MariaDB is a fork of MySQL and is supported by WordPress. You may find old articles referring to MariaDB being faster, but this is no longer true. (MariaDB used to use a faster DB engine called XtraDB, but all of the improvements in this DB engine have been merged into the InnoDB engine that ships with MySQL and MariaDB.)


Understanding your Cache Settings

Minification — Turn this on to automatically rewrite code to take up less space.

Grouping — With HTTP/1 always turn this on, but hopefully you are using HTTP/2 which allows multiple assets to be downloaded at the same time. However, there is a trade-off. JS and CSS can be compressed better when they are bundled into bigger files, and usually turning on the group JS/CSS option won’t group everything. I use webpagetest.org to try to determine if the browser is already busy parsing other JS/CSS and downloading other images to determine if grouping some of the JS/CSS files will result in better performance due to the improved gzipped sized, or if the resulting file is taking up most of the time than I won’t group them to allow smaller JS/CSS files to be downloaded in parallel.

DNS prefetching — For each third party domain that your website connects to, the browser has to take time to lookup the IP address associated with that domain. DNS prefetching allows the browser to begin the process of looking up these IP addresses earlier. I like to find all of the domains that are loaded before the domain ready event is fired, and add those to the list of domains to prefetch. Once again use webpagetest.org’s waterfall graph to find these domains (some caching plugins will automatically detect the domains for you).

Misc Improvements

InnoDB

If you’re database is still using a MyISAM engine, you’ll want to convert your database tables to use the InnoDB engine. This Stack Overflow answer explains how to do it. The MySql code needs to be entered into phpMyAdmin or into whatever DB manager your webhost uses.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.