Caching a WordPress website

Caching a WordPress website

Updated: 20/03/2019.

I already wrote about website caching in general. So now I won’t be explaining (again) what caching is, why it is important etc. Here I’ll write briefly about WordPress caching. What solutions there are and which one I chose and why.


1. Dynamically generated content

I touched this subject in the previous article on caching. Since you are riding this post now, it means I sat down, took the time to write it, save it and “publish” it. However, in its current form the post doesn’t exist normally. When a visitor asks for the article address, WordPress will read all the text from the database, all the formatting, pictures etc. and generate the post in a way it is presented now. It will do that each time, for each visitor. Content is dynamically created, it doesn’t exist in a static .html form.

Since posts on the website aren’t changed every day, it is clear what a waste of resources this presents. Good thing about dynamic content creation is the ease of content and design change. The bad side is higher server load. This is where caching steps in and can help:

WordPress website caching boils down to saving a once generated page version and showing it to each visitor – until the page is changed, or a predefined period of time has passed (see caching policy for details). It is usually done using caching plugins.


2. What about Cloudflare?

Yes, Cloudflare does provide some caching and content compression. Still, it’s no substitute for good WordPress website caching. To avoid any confusion: I certainly recommend Cloudflare, especially the free package, for any website. For more details, see the post: Cloudflare explained.

Here I’ll just note that some caching plugins offer “integration with Cloudflare service”. My experience has been such that it’s best to let Cloudflare do its thing, without the caching plugin “knowing” Cloudflare exists. Results without the integration set up have always been the same, or slightly better (faster and with better GTmetrix marks) than the “integrated” results.


3. WordPress caching plugins

On wordpress.org you can find a million different plugins of varying quality – same goes for caching plugins. Also, “Google” is full of: “best WordPress caching plugins”, “Top 5 caching plugins”, “Best 2019 plugins for caching” etc. I spent a lot of time testing different solutions. Here I’ll list a few caching plugins that I think are worth considering, with their pros and cons.

Note: for servers with LiteSpeed, LiteSpeed Cache plugin is by far the best option – see chapter 3.5.

3.1. Hyper Cache Extended

Hyper Cache Extended
Hyper Cache Extended

Hyper Cache Extended worked best on my, relatively slow and cheap hosting – same, or slightly better than the best other plugin tested. Having switched to Gutenberg (WordPress 5.0), main menu search option had stopped working – turned out this plugin was the culprit. That is why I had stopped using it. Otherwise it is really simple to set up and works fine.

3.2. W3 Total Cache

W3 Total Cache
W3 Total Cache

W3 Total Cache is a powerful plugin, but it has an enormous number of set up options. If you know what each option does and how it is best setup for your website (and hosting setup), then you needn’t read this post and I can only ask you to point me in the right direction for info and literature. Seriously.

Finding optimal setup by changing each option and then testing the site takes too much time. Number of permutations is great. Once it’s set up properly, it gives great results – among the best, if not the best. It’s just the question whether the time and the effort are worth it, since other plugins listed here aren’t drastically slower.

If you have enough knowledge, time and not the slowest hosting server, W3 Total Cache could be an optimal choice.

3.3. WP Fastest Cache

WP Fastest Cache
WP Fastest Cache

WP Fastest Cache is, with the ease of setup and good performance on a slower hosting, similar to the first caching plugin described here. Performance wise it is very close to well set up W3 Total Cache. Unfortunately, it also had problem with main menu search button of my website not working.

This plugin has Cloudflare integration that is best left untouched – at least for my website it worked better that way.

3.4. WP Super Cache

WP Super Cache
WP Super Cache

WP Super Cache by Automattic – the same company that is behind WordPress. This plugin is no speed champion. Ease of setup is moderate – I’ll list my setup in this post. The reason I chose this plugin is that everything works with it – 100% website functionality was in tact using this plugin. While it’s not much slower than the other ones.

Edit from 14 February 2019: because of a change of hosting server, I’ve switched to using LiteSpeed Cache plugin, see chapter 3.5. for details.

Now I’ll offer a list of pictures that show my setup. For websites where content is refreshed often, cache expiry/refresh times can be set at half time shorter, or even more.

First setup page – enabling caching
First setup page – enabling caching
Advanced setup options
Advanced setup options
“Cache Location” directory should be left as it is “by default”
“Cache Location” directory should be left as it is “by default”
Cache timeout setting
Cache timeout setting
Enabling cache preload for all the pages
Enabling cache preload for all the pages

That’s the setup I’ve used. All the options are left at the “factory default”.

3.5. LiteSpeed Cache

LiteSpeed Cache
LiteSpeed Cache

If website hosting server is a LiteSpeed one, then by far the best caching option is LiteSpeed Cache plugin. This free plugin does caching, code minimization, as well as database optimization (thus replacing WP Optimize for example).

Performance wise, no other plugin comes near – of course, only if the server is LiteSpeed. That is: for non-LiteSpeed servers, this plugin is not the best option.

Pictures below show page load times of the same page, on the same website, first using WP Super Cache, then using LiteSpeed Cache:

Page load times using WP Super Cache plugin on a LiteSpeed hosting server
Page load times using WP Super Cache plugin on a LiteSpeed hosting server
Page load times using LiteSpeed Cache plugin on a LiteSpeed hosting server
Page load times using LiteSpeed Cache plugin on a LiteSpeed hosting server

Tools used for performance measurement.


And that’s it. Leave any questions, or suggestions in the comment section below.

Share...

Leave a Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.