In this series of Optimising a WordPress site, in this post, we are going to talk about how to setup WP Total Cache Plugin on WordPress.
Before we move on to the technical part, let me just tell you how WP Total Cache works, and why you should use it.
How Does WP Total Cache Work?
What a Cache plugin does is, it caches all the static files of a site, so that when the user browses another page (within a certain period of time, like 1 day or a week) all the static files will be rendered from the cache stored in the browser, making the site load faster (as there is fewer files to load).
In WordPress, when you visit another page, just the content area changes, the Header, Sidebar, Footer, etc remains the same. Using a Cache plugins can help you serve only the content area of another page.
There are tons of plugins available for caching purpose, but mainly there are two of the most popular Plugins, WP Total Cache and WP Super Cache, I’ve used both but I liked WP Total Cache plugins because of its flexibility and options over the Latter.
Things to Do Before Installing WP Total Cache
Before installing WP Total Cache plugin on your WordPress site, make sure you test your site’s performance using Pingdom tool, this will tell you the current performance of your site. Also, keep using the tool at every step to evaluate the effects of each setting on your site.
Also, make sure you have no other Caching Plugin enabled, For Example, WP Super Cache.
How to Setup WP Total Cache
Head over to the Add Plugin section on your WordPress dashboard, and then search for the term ‘WP Total Cache’, the WP Total Cache plugins would probably appear in the first line of results. Click on the ‘Install’ su_button and on the next page, click on ‘Activate the plugin’
On the page reload, you will see new options appear below the Settings section of your WordPress dashboard, called ‘Performance’.
When you click on it, don’t get overwhelmed with too many options, simply click on No or Cancel option to disable the features the Plugins asks you do turn on automatically.
Under the ‘Performance’ tab, you will find many other options like General Settings, Page Cache, Minify, Database Cache, Object Cache, Browser Cache, her Agent Groups, CDN, Monitoring, etc.
This might seem like too many options, but it’s not because we only need to use Page Cache, Minify, and Browser Cache for our sites. But we will talk about each setting individually to give you a clear idea of what it is.
Head over to the General Settings from where you can enable and disable all the features you want for your site and then go to the more settings page of the respective options to make changes if you enable them. Let’s talk about each feature one by one and whether to turn it on or not.
Page Cache
The Page Cache option is exactly what it says, this option creates a cached copy of pages browser by users so that next time they visit the page, it gets loaded from their cache instead of requesting from your site (more the requests, longer it takes to load the page)
So, keep this options enabled and keep the cache method to Enhanced.
In the Page Cache section, where you will find many options to make changes to the strings, there is not much you need to change. The default settings should work fine.
Minify
A website consists of several file types, such as, HTML, CSS, Javascript, Media Files (.png, .jpg .gif etc). What this feature does is, it turns the type of each file into a single file to make it easier and faster to load.
It removes spaces between the scripts, and make it look like one big file instead of many small files, which takes less time to load.
Its option has a bunch of options and you need to give attention to what you are going to enable because some themes might break after to choose to Minify the HTML and CSS files or Minifying Javascript can make the site not load at all.
The best thing would be to start with Minifying one file type, and check whether your site is loading fine if it breaks, stop and uncheck the particular option to stop Minifying the file type.
Database Cache
This option reduces the server load by caching the SQL queries made to load the page.
If you have a simple blog type site which doesn’t have too many plugins and flashy features and which isn’t a very old site with a big database, this options won’t make much difference.
I’ve kept this feature turned off.To check whether this feature makes different to your site’s performance, simply enabled and check your site’s performance using the Pingdom tool and see if it affected or not. Do this after you are done with all other steps including the steps mentioned below.
Object Cache
This option is useful for highly dynamic websites with a complex structure. Think of websites that have a lot of stuff going on their homepage. I’ve turned this feature off as it didn’t make much difference to my site’s performance.
Browser Cache
This is the options which makes some good effect on you site’s performance, turning this feature on, makes the browsers of users to cache all the static files, such as Images, CSS, Javascript etc in a temporary folder and server these files from there when the user goes to another page, making the page load instantly as there is not much to load from the website.
Enable this feature and to go the Browser Cache tab for more options.
I’ve enabled everything except the last option ‘Prevent caching of objects after settings change’ as this added some extra strings to each of the images on my blog like xyz.jpg?34243 (more about this here)
When you scroll down in the Browser Cache settings page, you will be able to make changes to individual file types such as CSS & JS, HTML &XML, Media & Other Files, but everything should work fine with the settings made in the General section.
I changed the Expires header lifetime in the ’Set expires header’ option of all the file types. I’ve set them to 1 week, (60x60x24x7=604800 seconds)
CDN
The concept of CDN (Content Delivery Networks) is quite simple, it’s a feature offered by different services to distribute your content to the users from their nearest servers, cutting the travel time and making the site load faster.
One such CDN service is MaxCDN, which is a paid service, but it’s very effective if your site has a lot of images.
I am using Cloudflare, which is also like a CDN but the setup is a bit different and doesn’t require you do make changes in the WP Total Cache.
Other Options
Such as User Agent Groups, Referrer Group, Monitoring etc can be ignored as they do not affect the performance of the site.
This marks the end of this guide, just to recap, here are the following options you should enable.
- Page Cache
- Minify (make change in the minify settings page)
- Browser Cache