You all know how much I love caching, but what is it, and should you be using a caching plugin on your WordPress site?
What is caching?
Well, on WordPress, page caching is (usually) storing the output of a page as a static file. This static file is generated the first time a user visits the page, or some plugins will automatically cache pages before anyone vists them. This static file is then served to visitors instead of dynamically generating the same page time and time again. This means that pages require less generation time, can be served faster, and to more people at once. It also reduces server load, which means your site is less likely to crash, especially if you’re on shared hosting.
You’re probably thinking that this sounds amazing and should be built into WordPress. While caching does help with many problems, it also creates new ones. For example, pages are stored in a static form, which means that new comments will not be displayed until the cache is refreshed(unless you’re using something like Disqus). Most caching plugins will do this for you automatically, which means you don’t have to worry about that, but there are still other problems. Caching pages also means that server-generated objects will be the same for everyone. This is the main reason that caching plugins to not cache pages for users who are logged in. Caching can also break some other aspects of your site, such as log-in pages, registration pages, etc.
Should you use a caching plugin?
This depends on a lot of things, but for the most part, yes. However, if you run a site that has most of your visitors logged in, or if your site receives a lot of comments, you might not see any benefit. In some cases, your site can become slower because constantly creating new cache files and removing old ones puts a lot of strain on the disk, especially non-SSDs. Also, if you’re on VPS or dedicated hosting, your site can probably live without a caching plugin, and load fast enough.
One thing you might not have known is that WordPress actually does have its own built-in form of object caching. Using a query monitor plugin, I’ve observed hit rates of over 90% even on
wp-admin. However, the built in cache only lasts for one page load, and will be regenerated each time a user loads the page.
By the way, if you’re hosting WordPress by yourself, a caching plugin such as W3 Total Cache or WP Super Cache can serve pages even if you break the database, or even PHP. This has already saved me multiple times, and is the reason I usually enable cache pre-loading, so even pages that weren’t visited get cached.
There are tons of WordPress plugins available, and each one has its own set of features. Each site has different needs, so please do some research before installing a caching plugin to find out which one will work best for you. Here are a few to get you started: