Sure, you have a great website.
But you’re also competing with hundreds of websites for the spotlight. Performance optimization is not something you can skip on.
And the easiest way to do that? – Caching!
An optimized website ensures that visitors don’t bounce off right in the first few seconds. Even better, Google loves them. It helps you rank better on search pages, driving more traffic to your website in the first place.
And while caching may sound like an overwhelming and complicated concept, it’s actually really easy to set up using a WordPress caching plugin.
But before we see how to do that, let’s talk about picking the right caching plugin.
How to choose a WordPress caching plugin
There are a plethora of WordPress caching plugins on the repository.
In this article, we will be talking about W3 Total Cache. It’s a plugin that we use and it works for us.
But that might not be the case with your website.
Here are a few factors you should take into consideration:
Factors you need to consider when picking a plugin:
- Budget: There are plugins like W3 Total Cache that are totally free, others like WP Rocket are paid, while most others have a freemium model. Your choice depends on how much you’re willing to spend for the features you need from a cache plugin.
- Type of website you have: If you own a membership-based website, full-page caching might not be ideal. So you need a plugin that allows fragmented or partial caching. Similarly, an e-commerce website, with a large database, needs a plugin that offers database caching.
- Level of Expertise: Some caching plugins are geared towards beginners while others have more advanced level settings. Pick a caching plugin depending on how much control you want over your caching policy.
Some basic caching features are good to have regardless of your type of website. The next section lists those features:
Features that are good to have in a caching plugin
- Page Caching
- Object and Database Caching
- Ability to purge cache at any time
- Exclude pages from being cached
- Browser Caching
- Gzip compression
- CDN support
If you’re looking to explore, we’ve compiled a list of 7 best caching plugins. You can check it out to see features, pros and cons, and user reviews. It should help you make an informed decision.
Things to know before setting up caching
Caching is essentially a way to reuse previously generated data.
Caching is great for static pages that don’t change often. This would be your home page, about us or contact us page. But if you cache a page that changes frequently, there’s a chance that your user views the older version.
Which is why you need to purge or clear your cache when you make any changes. For example, say, after you put up a new post or when you approve a new comment.
Now, let’s get down to business and talk about setting up caching on your website.
Setting up Caching on WordPress using W3 Total Cache – A complete guide
In this article, we’ll be using W3 Total Cache to set up caching. It’s a plugin we use and it has helped us improve our website speed significantly.
W3 Total Cache is a popular WordPress caching plugin with a comprehensive list of features. Which means that it works for most websites.
W3 Total Cache also comes with default settings to make it easier for you to navigate all the features.
1. Install and Activate W3 Total Cache
You can get the plugin off the WordPress.org repository or through the Plugins section on your Dashboard.
Once you Activate the plugin you’ll see a ‘Performance’ tab added to your Dashboard. This tab contains various settings pages for all the features.
2. Configure General settings
This is the page you can use to conveniently enable or disable caching options. Each option also has its own detailed settings page. We’ll go through each later in the article.
You can enable or disable:
- Page Caching
- Database caching
- Object Caching
- Opcode caching
You can also turn on Preview Mode here. It allows you to see how your settings work before you actually make them live.
For each option, you’ll also see three buttons:
Save all settings: This saves the changes that you’ve made
Empty Cache: ‘un-caches’ the pages that you’ve previously cached and rebuilds the cache
Save Settings & Purge Cache: Saves your new settings, empties and rebuilds your cache
3. Set up Page Caching:
The first settings option we’ll talk about is page caching.
Page Caching allows you to cache your website pages. It is a key aspect of optimizing your performance and reducing page load time. We’ll be discussing the sections on this page in brief:
a) General Settings
It contains basic settings about which part of your website content should be cached.
Important settings you need to review :
- Cache Post Pages: Ensure that this is enabled. These pages usually have a lot of traffic and need to be optimized.
- Cache SSL (HTTPS) requests: Enable this option to cache https requests
- Cache URIs with query string variables: Caches your search results. Enable this to load search results quickly on your website.
- Don’t cache pages for logged in users: Important for keeping your site secure
- Don’t cache pages for following user roles: Exclude certain user roles from viewing a cached version of the website Eg. Admin
If you have mirrors of your website with the same content, you can add them here and have W3 Total Cache work for them as well.
c) Cache Preload
Once the cache expires, it needs to be rebuilt the next time the user visits the page. This can be avoided by preloading the cache.
Using the plugin you can specify the ‘update interval’ & ‘pages per interval’. Choose to enable this option based on your server performance.
d) Purge Policy: Page Cache
When you create posts or add comments, your cache needs to be emptied and rebuilt. This section allows you to select the pages & feeds that need to be purged.
4. Configure Minification settings
Epitrove’s Tip: Minification is not really a straightforward process. There’s a chance it might not work for your website because of the way it’s coded and which server, plugins, themes you’re using. This is one option you might want to run on Preview Mode. Contact your developer if you have trouble.
Most of the minification settings you need, you can find on the ‘General Settings’ page.
For example, you can pick the ‘minifier’ for each type of file. But unless you have a particular preference, I suggest you leave it on the default settings.
If you are customizing settings, be sure to select the ‘Manual Mode’.
5. Enable Database Cache
All your website data like your users, inventory, etc are stored on a database. Each time this data is required, it is fetched from this database.
However, if your website is data-heavy, fetching the same data over and over is not feasible. In this case, a database cache not only improves your page response time, it also reduces the load on your server.
There aren’t a lot of sections of the Database Cache page, but here are the important settings:
Don’t cache queries for logged in users: Enabling this option is important for the correct functioning of WordPress.
Other advanced settings can be configured based on your website’s needs.
6. Enable Object Cache
An Object Cache stores database query results.
If a query is made often, it doesn’t make sense to fetch the results from the database every time. Instead, the result is stored and fetched from an object cache.
This also reduces the load on your server in addition to improving your speed.
7. Configure Browser Cache Settings
To optimize page load speed, the web page content is often stored in a browser cache.
Instead of fetching it from the server every time the page is refreshed, it is easier to fetch it from the cache.
The Browser Caching settings page is a little overwhelming with a long list of configuration settings. Below are the things you need to know to figure them out. For CSS, JS, HTML, XML, Media and Other files you can set them up separately.
Browser Caching Terms you need to know:
Last-Modifier header: Http header that contains date and time when the resource was last updated. It can be used to verify if the content in the cache is the same as the latest version.
Expires and Cache-control header: Http headers that define browser caching policy for different resource types. Primarily, how long they should be cached. You can define these separately for HTML, CSS and JS, etc
Etag: It’s a validation token, essentially works similar to a browser cookie. It determines which resources need to be requested from the server when the user returns to the website.
Gzip and brotli compression: Used to compress and reduce the size of files. It’s a quick way to speed up your website. Gzip compression has been around for a while brotli is relatively new. Either do a fine job of compressing your website.
Disable cookies for static files: Static pages don’t change when the user revisits your websites, cookies can be disabled for them.
Security Headers: You can add these for added website protection. The setting options all have explanations telling you what it does and there’s a ‘quick reference chart’ to help you out.
8. Add your CDN to the caching plugin
A Content Delivery Network is a group of computers that are scattered geographically.
This helps deliver content quickly and also decreases the load on the main server by storing cacheable content.
If you use one, W3 Total Cache allows you to add your CDN provider from the General Settings page:
You can pick which content you want to host on the CDN from the CDN settings page:
- Enable Lazy Loading using the General Setting page to optimize resource usage
- You can enable statistics collection to monitor cache usage. Note that this a premium feature
- W3 Total Cache has a debug mode you can use to find bugs if something goes wrong
Drawbacks of W3 Total Cache + Other popular alternatives
While W3 Total Cache has a free version, support is only offered with the premium plugin. And without extensive documentation, having to figure out the plugin settings can get overwhelming.
Over to you
Now, adding a caching plugin to your website is an important step in optimizing your website. However, be sure to understand caching and how it affects your website.
I hope that this article helps you speed up and optimize your website. If you have any other tips, plugins you would like to recommend or if you want to share how caching has helped you, please do write to us in the comments!
Disclosure: Some of the links in this blog post might be affiliate links. When you purchase through a link on our website, we receive a small commission, at no added cost to you, which helps us run Epitrove and keep producing great content. This does not influence our recommendations; we only recommend products we work with or love. Thank you for your support!