Resolving Slow WordPress Websites

Sharing is Caring

Slow WordPress websites can be difficult to improve especially if we don’t have a plan on how to resolve the problem. I have a list of five recommendations that I always look at doing when trying to resolve speed issues.

Here’s my TOP 5 recommendations to solve it.

  1. Remove all unnecessary plugins.
  2. Cache and minify it. (WP Rocket, or raw Apache / Nginx can help here!)
  3. Images should compressed.
  4. Get a content delivery network (CDN) with a good number of edge locations so resources are loading from locations close to your users. If you’re using AWS it’s time to look at CloudFront.
  5. Ditch hosts. Do this first if you’re on shared hosts like GoDaddy, Bluehost, Inos (1&1).

After evaluating these five tips would be the only time I would really consider changing themes. The theme isn’t always the problem and can usually be resolved through caching, cdn’s and minification.

#1 Remove All Unnecessary Plugins

WordPress out of the box isn’t slow, it’s all the stuff that we add to it that makes it slow.

“There’s a plugin for that” tends to be the answer in the WordPress community. It’s great that there’s so many plugins available in the community, but the plugins all add complexity and additional code or database joins that may need to execute on every request to the server. All of this additional complexity can come with a speed cost.

When I look at lists of plugins, I always ask myself the following questions:

  1. Do we really need this plugin?
  2. Is the plugin a must have? Do we really need three separate sliders?
  3. Can this be resolved on the server-side in Apache or Nginx instead of in WordPress?

Page Builders, and WordPress security plugins tend to be really bad culprits for bad website performance. The newer WordPress Block Editor (Gutenberg) and Advanced Custom Fields can potentially replace builders like BeaverBuilder.

Some of these can be resolved though by caching, minifying things, and using a content delivery network like Cloudflare or Cloudfront.

#2 Cache and Minify the Site

If you are using Apache there’s a number of tweaks that can be made to speed up websites. The majority of these tweeks are apache modules which should require very little effort. Most of them can be resolved in under a few hours.

mod_expire mod_deflate mod_http2 are all great options from Apache to improve caching.

mod_expire

mod_expire allows us to set caching headers which means the browser will avoid redownloading the resource again and the content delivery network may not request an updated version.

For mod_expire, I generally add the following to my apache configuration:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>

See blog post Setting Up Caching on Apache for some more details.

mod_deflate

mod_deflate compresses the page over http and allows it to be downloaded faster on lower bandwidths or mobile devices. It’s one of the easiest ways of improving the GTmetrix or lightsail scores.

mod_http2

mod_http2 is a decent way of improving webspeed by using different threads for each client. It has the advantage of improving website requets without necessarily needing to redo any programming.

Caching Plugins

I avoid most caching plugins because I feel like they don’t really do much that regular old apache or nginx can’t do without a bit of tuning. There are some exceptions though.

WP Rocket is a great premium caching plugin that helps with minifying and caching. It can really help with making static HTML versions of content which helps reduce the database load which is where a lot of the timing is like spent.

#3 Compress Images and Videos

Images can be compressed pretty easily by using Save for Web in PhotoShop, or by using a service like Kraken or WebSmush. In some cases, you might want to use the webp image format instead and no longer use jpg or png files.

Videos are more difficult to compress but there are some options. Usually it’s best to start with your video editor and turn down the frame rate a little bit. I’ve used a few different video compression services and haven’t been particular impressed by any of them.

#4 Get a Content Delivery Network

A content delivery network (CDN) is a large network of proxy servers and data centres. The goal of a good CDN is to provide high availability and performance by delivering content closest to users. There are quite a few different CDN providers and they are definitely not all equal. Cloudflare, Akami and Cloudfront are definitely the leaders in this space.

With most of them the first step is pointing your domain name directly to their name servers and then migrating your different subdomains and txt records to them. It’s a fairly large and highrisk job – I don’t recommend doing it unless you absolutely have to.

#5 Change Hosts

Most people immediately jump to changing web hosts which doesn’t always fix the problem. The problems are usually a result of underlying issues with the website.

Most websites don’t need to execute a database query, and send 90 resources to the client’s web browser. Most of the time, our WordPress webserver shouldn’t even be sending the css, javascript, and images.

If your WordPress website is property architected the only things that should be loading directly from it are pages or sections that are personalized, and the contact forms.

Measuring Improvement

GTMetrix or Chrome Lighthouse are good ways to measure your changes. Keep in mind this is a proxy and not perfect though.

Sharing is Caring

Brian is a software architect and technology leader living in Niagara Falls with 13+ years of development experience. He is passionate about automation, business process re-engineering, and building a better tomorrow.

Brian is a proud father of four: two boys, and two girls and has been happily married to Crystal for more than ten years. From time to time, Brian may post about his faith, his family, and definitely about technology.