WordPress is, by default, a dynamic content management system and this means that it must look for every page a visitor requests in the database just to see if it exists.
In most cases, especially where a website doesn’t get too much traffic, this isn’t a problem but, should there be a surge in traffic, your WordPress site will suddenly start using enormous amounts of CPU resources while trying to deal with duplicated requests, over and over.
Stopping this is quite easy to do by using the right caching plugin.
A caching plugin caches the first request from a visitor for a page on the server, in plain HTML so that when that page is requested again, by another visitor, that cached version is served – so long as the page hasn’t been updated in admin or with a comment in the meantime.
This reduces that amount of CPU usage significantly.
Let’s say that you have 50 separate views of your main page and it hasn’t been cached. That would mean 50 queries on the database, each time it just goes back to the same data.
By using a caching plugin, only the first request would be queried on the database and the next 49 would get the cached version immediately, no having to wait for the query to complete.
This is a win-win – you get a reduction in resources used and your visitors get a quicker loading time.
W3 Total Cache
One of the easiest caching plugins to use in WordPress is W3 Total Cache and I’m going to show you how to use it.
- In your WordPress dashboard, hover your mouse over Plugins and choose Add New
- Type W3 Total Cache in the search box
- Click Search Plugins and then click Install Now under W3 Total Cache
- A window will pop up, click OK
- Now click on Activate Plugin and you will see a message telling you the plugin has been activated
- Go to the menu on the left-hand side and you should see a section called Performance – hover the mouse over it and click General Settings
- Scroll down the page and make sure that each of the main parts has been enabled.
Those parts are:
- Page Cache
- Minify*
- Database Cache
- Object Cache
- Browser cache – click Save All Settings once you enable this one
* If you use Minify, enable the option and save it. Straightaway, go straight to your website and make sure it all looks good.
If there are any formatting issues, a plugin or theme may be incompatible with minification. If this is the case, you will either need to change the theme or plugin or disable minification
Now make sure that the following have been check marked and click Save All Settings:
- Cache home page
- Cache 404 pages
- Cache feeds
- Cache requests only
- Don’t cache pages for logged-in users
Lastly, ensure that everything has been correctly set up and then go to your website. Open your site, click on View and then Page Source so that you can see the page source.
Scroll down, right to the bottom and you should see a banner for W3 Total Cache. This will tell you that the plugin has optimized your page
When you have confirmed it all and your website is running perfectly, you are done. W3 Total Cache will ensure that your pages load faster, and fewer server resources are used, resulting in happier visitors and fewer bounces.