Do you want to disable caching for specific pages in WordPress? You have come to the right place. In this tutorial today, we will show you how to exclude specific pages from caching in WordPress.
Page caching is crucial for website speed. But in some cases, you need to disable caching for specific pages in WordPress sites. The pages like custom login/logout URLs should be excluded from caching. Apart from these pages, you might have some other pages that you don’t want to cache.
So, how can you exclude specific pages from caching in your WordPress site? Let’s find that out in this tutorial below in some easy steps.
How to Disable Caching for Specific Pages in WordPress
Disabling caching for specific pages means you have enabled caching for all the pages in your WordPress site in the first place. And, if you did that you might have used a WordPress caching plugin or a system provided by your website host to cache your WordPress site.
In our tutorial, we are showing how to disable caching for specific pages in WordPress if you are using the WP Rocket plugin. If you are wondering why we are doing that, you can read our detailed review of the WP Rocket plugin.
It is not only the pages that you can exclude from caching. Since WP Rocket lets you disable caching using URLs, it can be applied to any page, post, taxonomies, or anything else that has a URL on your site.
Step 1: Install and Activate WP Rocket Plugin
As you keep reading the post, I assume you are using WP Rocket or have the intention to use WP Rocket caching plugin in the future. Get the WP Rocket plugin from their website. Install and activate the plugin.
WP Rocket is a premium plugin, so you can not get the plugin on the search box on your dashboard. You have to get the plugin from their website and install and activate it manually.
Go to your Dashboard > Plugins > Add New, and click on Upload Plugin beside the Add New option. Upload then install and activate the plugin subsequently.
Step 2: Go to Advanced Rules of WP Rocket
Once you have the WP Rocket plugin installed and activated on your website, you can start the process easily. Login to your WordPress site then go to Dashboard > Settings > WP Rocket > Advanced Rules.
Note: By excluding pages from the cache, you are also excluding them from all other optimizations available in the WP Rocket plugin.
Step 3: Disable Caching for Specific Pages in WordPress With URLs
Now locate the box “Never cache URL(s)“. Place URLs of pages or posts that you want to be excluded from caching. You can enter the full URL e.g. http://www.example.com/page/ or you can enter the part after the domain name, e.g. /page/. Either way, this will work.
If you want to have multiple pages to exclude, place the page on its own line:
Click on the SAVE CHANGES button at the bottom to finally disable caching for the specific pages in WordPress site you want.
Step 4: Exclude a Group of Pages at Once from Caching
Apart from excluding single and multiple pages from caching, you can use Regex to exclude a specific set of pages too.
For example, you have an events section on your site and you want to exclude all the event pages. Assuming they are set up as child pages their URL structure is like the below:
You can exclude all, of them by using (.*) wildcards to address multiple URLs under the given event path.
But this won’t exclude the parent page /events/. To exclude the parent page, use the following one.
Exclude Individual Pages from Caching Directly in Page Settings
If you are using WP Rocket, you can exclude individual pages directly in the page settings too. Go to the page or post you want to exclude from caching, and find the WP Rocket settings on the right sidebar. Checkmark on “Never cache this page”.
Also, you can set up the optimization for that particular post or page too by activating the options under it.
Note: None of these options will be applied if this post has been excluded from the cache in the global cache settings.
Automatically Excludes Certain Pages in WordPress From Caching
There are some dynamic plugins WooCommerce, BigCommerce, and Easy Digital Download have some specific pages that carry data (such as the items in their shopping cart). These data should not be cached. WP Rocket automatically excludes the “Cart”, “Checkout”, and “My Account” pages from the cache for these plugins.
So, you don’t need any settings to exclude these pages carrying data.
There are a lot of caching plugins in WordPress. However, not all of them provide such options to disable caching specific pages in WordPress. Some of them require you to apply codes to do that. We found WP Rocket user-friendly and very easy for beginners to set up and apply these captions without writing any code. That is why we have chosen the WP Rocket caching plugin to do so.
Above all, when it comes to optimizing your WordPress site for speed, WP Rocket would top the list with its features, functionalities, and ease of use. Get WP Rocket and have granular control over your website optimization.