What is Caching? The What, the Why and the How with WordPress.
The What
Web designers and developers often recommend caching your website in order to improve its speed and performance, but what is caching exactly?
Caching is the act of storing a full web page or elements of a web page for use later. Browsers tend to do this automatically for most types of websites.
The Why
The main reason sites are cached is speed. If you have visited a site previously and you have a copy of at least parts of the site on your computer, it will be much quicker to load that than calling the website and requesting the data again.
Normal HTML and PHP sites are cached quite easily by the browser, but dynamic PHP and CMS sites, for instance WordPress have a bigger problem as the content changes often.
The How
There are two core types of caching: Browser and Server.
As mentioned above browsers will attempt to cache parts of a website, specifically those elements that the web developers or caching plugin specify to cache (often unchanging things such as JavaScript and CSS files).
These files are actually held temporarily on your computer, there is normally a specified limit in the browser settings.
Server caching is more complex and outside of the scope of this article but basically the server will store the data in a similar way as a browser would and serve that data if conditions are met.
Most systems for caching WordPress pages use a mixture of both server and browser caching. The main thing is they convert the dynamic content into a standard HMTL file and then when the visitor goes to the site, they get shown this specially created page. When content is updated on the site, the cache is re-created to reflect the changes.
WordPress
Whilst caching can be a technical exercise, the wonderful WordPress community have made caching plugins that can be installed and pretty much left alone, but have a myriad of options should you want to fine-tune things.
The main two plugins that come to mind have been around for a number of years now so excel at what they do: WP Super Cache and W3 Total Cache.
I personally prefer W3 Total Cache as it allows extreme tuning, but WP Super Cache has an easier feel to it. Both do an excellent job of caching and the average user will only see a speed increase regardless of which plugin is installed.
Both plugins are free and available on the WordPress Plugin Directory.
A Word of Warning
For most types of sites, caching is a boon; beneficial to both visitors and admin alike.
However some types of sites need to be careful with caching as it can affect the visitors experience in a negative way.
Sites such as ecommerce or event management systems, basically anything that has to quickly update elements like stock, should use cache carefully.
Most of the time you can set it to cache part of the site and avoid problem areas like shopping carts, so if you own a site like that you cannot set and forget a caching plugin, it must be setup correctly.