Caching in WordPress- Why and How?

Category: Intermediate

Let’s say you have had your site for quite some time now and it gets a good number of hits. With steady increase in traffic for your site, there is one minus, however. Once the popularity of your site crosses a certain limit, your server’s capabilities will be tested and rendering pages might become very slow. Worse still, the server might crash if there are too many requests at the same time. What could you do then to avoid such a situation?

Caching comes to the rescue. Cache is basically a component which stores some data that makes future requests faster. It improves the user experience in your site by improving server performance, which, in turn, leads to pages loading faster, static files like images and JavaScript downloading faster. There are many ways in which caching takes place for a website, the most popular of which are explained briefly later.

There are various plugins that perform the task of caching in WordPress, but we would be using W3 Total Cache, arguably the best caching plugin available online.

W3 Total Cache:

W3 Total Cache is perhaps the best caching and performance optimization plugin out there for WordPress. It is trusted by sites of big players on the market like AT&T, Mashable, CSS Tricks and Web Designer Depot. The W3 Total Cache plugin for WordPress offers caching abilities are page caching, database caching, browser caching and delivery through a content delivery network (CDN).

Installing the plugin:

Head over to the official page for the plugin on the WordPress site or search for W3 Total Cache in Plugins > Add New. After installation, activate the plugin, which will add a new item ‘Performance’ on your left menu.

Configuration and Settings:

If you just click on the Performance tab on the left, you could be overwhelmed because the powerful plugin that W3 Total Cache is, there are a lot of options to customize.

In general settings, you are asked the basic things regarding all the settings provided by W3 Total Cache.

You can enable page cache, which would save static pages to render requests faster. This way of performing caching creates static pages for popular pages and renders them unless there are changes in the pages since the time they were cached. This doesn’t make requests to the database, rendering it through PHP for every page load but shows the cached copy instead.

You can also minify your static files (CSS, JavaScript) to reduce file size and loading time. Do note that although the minify option reduces the file size, it might not be compatible with all servers, resulting in server crashes. Therefore, you should use this option with caution.

You can enable Database caching to cache the responses of the database to SQL queries, or object caching to reduce execution time for common operations. Do note that database caching is best used when object caching is disabled.

You can also enable Browser Cache, which would use HTTP compression and add the necessary headers to cache the static files in your browser. Browser Caching helps reduce server load by reducing the number of requests while rendering a page. Static files like CSS, JavaScript and images, on loading the webpage for the first time, are cached in the browser and on subsequent requests, are not re-downloaded from the server for display (if they haven’t been changed since the last time). This reduces the page load time, as well as putting less pressure on the server.

Server Caching is a bit more complex and can be done in a variety of ways. A simplified version would be to use caching servers, also called reverse proxy servers, which act as in intermediate between the end user and the actual web server that hosts the WordPress site.

You can enable the content delivery through a CDN (Content Delivery Network). The most popular (and the one mentioned in the dashboard of this plugin) is the MaxCDN. Do note that CDN services are separate and you need to add them as a CNAME in your domain after setting them up, a process which is beyond the scope of this blog post.

After you have setup the plugin, make sure you export the settings. This would help you if your site crashes, or if you want to revert to the original state on changing something by mistake.

We hope that this post helped you in understanding the complex process of caching of a site and increase the performance of your site in the process! If you have any queries, feel free to leave a comment below.

Author Bio

Shaumik Daityari

Shaumik is an optimist, but one who carries an umbrella. An undergrad at IIT Roorkee, he loves writing, when he's not busy creating some awesome stuff. Find him on and Twitter.

Leave a reply

Appointment Booking Plugin for Wordpress