W3 Total Cache is one of the top free caching plug-ins for WordPress, with more than 1 million active installations. However, it needs to be set up correctly on your site to cache the page and work properly. There are hundreds of settings available under different sections, and it’s easy to get lost. It is easy to make mistakes in the settings, which can affect the speed of the page and damage the layout of your site. Especially if you use a lot of JavaScript on your page, you should thoroughly test W3 Total Cache (W3TC) on your staging or test site before deploying to a real-time site. When you find that some pages have a messy layout and want to exclude them from the cache, here is a detailed tutorial.
Why exclude specific pages and directories? There are many reasons why
excludes specific pages or directories from the cache for proper loading. It depends on the themes and plug-ins you use on the site. Here are some common examples of problems encountered by the W3 Total Cache plug-in:
- when you have a WooCommerce plug-in, product and shopping cart pages are usually interrupted by the W3TC cache.
- using slideshow carousel with jQ uery or JavaScript destroys the cache and does not load correctly, especially on mobile devices. Most
- page builder plug-ins (such as WPBakery) come with blog rotation elements that do not work in W3TC.
if you use themes that rely heavily on jQuery, you need to disable minimization of JavaScript (minification) to load the page correctly. Fortunately, W3TC provides an option to exclude pages and directories using wildcards so that you can easily exclude them from the cache.
feels that W3 Total Cache settings are complex for friends, you can try the WP Rocket advanced plug-in to speed up your site. You will be surprised by the minimum setting and the improvement in the site’s page speed score.
excludes pages and directories from the W3 Total Cache plug-in cache.
logs in to your WordPress administration panel and navigates to the “Performance & gt; Page Cache” section. Scroll down to the “Advanced” section and find the “Never cache the following pages” option.
W3 Total Cache Page Cache Advanced Settings
you will see that the plug-in has added several lines to the text box, as shown below.
wp-.*.php index.php
enters the page URL and directory in the “Never cache the following pages” text box to exclude them from the cache. Again, scroll down to the bottom and click the “Save Settings & Purge Caches” button to clear the old cache and save your changes. How does
enter page URL and directory?
W3 Total Cache allows you to enter pages and directories that you want to exclude from the cache in a variety of ways. You can use URL, directory names, wildcards, and regular expression formats. When entering your details, be sure to follow the following guidelines:
- enter a whole per line, which can be a page URL or a directory.
- URL and directories are entered into your domain as relative URL. This means that you need to ignore the site address and enter only the rest.
the following are some sample exclusion rules you can enter:
exclusion format | expected results any content starting with / showcase after the |
---|---|
/showcase* | domain name will not be cached |
/shop* * | all store pages will be ignored |
/demo/ | only the demo directory will be ignored |
/post-name/ | specified article URL will not be cached |
/page-url/ | specified page URL will not be cached |
excludes content from the cache other possibilities
except articles, Outside of pages and directories The W3 Total Cache plug-in also allows for other possibilities. These options are available on the Page Caching menu under Advanced.
excludes articles in a specified category
you can exclude all articles under a specified category by mentioning the category tag in the “Never cache pages associated with these categories” text box. For example, if you have a category called “technology”, just fill in its slug without a leading or trailing slash. The plug-in will exclude all articles under the “Technology” category from the cache, and users will view non-cached pages.
excludes articles based on categories in W3TC
excludes articles with specified tags
is similar to categories, you can ignore articles in the cache based on tags. Remember to enter a marker segment without a slash.
excludes tag-based cache
in W3TC excluding author-based articles
entering one author name per line in the “Never cache pages by these authors” box. This excludes all articles for the specified author from the cache.
based on author name exclusion page
excludes articles based on custom fields
custom fields are additional fields where you can store relevant data in WordPress. You can add custom fields to your articles and pages using the default WordPress custom fields available in the Gutenberg or Classic Editor. Later, you can exclude the page from the cache based on the custom fields you added in the editor. The format of the entry should be similar to “custom filed=value”, as shown below.
excludes the page
based on custom fields beware of other options
as mentioned earlier, the problem with the W3 Total Cache plug-in is that you can easily get confused about the settings. In “Never cache…” . ” Below. Option, you will find more options that have nothing to do with excluding pages, in fact, they are used to include in the cache.
- has another option called “Cache exception list”. The plug-in will cache any URL or directory you enter in this box, regardless of whether you have excluded it using one of the above exclusion methods. Therefore, be sure to keep this box when you exclude pages from the cache.
- In addition, the “Non-trailing slash pages” option is useful for caching pages that contain no trailing slashes. Typically, you can use it to cache XML site maps and other files that do not have slashes in WordPress. Therefore, to exclude pages from the cache, you should not enter URL or directories in this box. Finally,
- retains the “Specify page headers” section, which is also used for caching pages, not for exclusion.
W3TC caching options