W3 Total Cache is one of the top and free caching plugin for WordPress. But most of the time wrong setup will reduce the speed and break the pages. Especially when you are using lots of JavaScript then you should test the W3 Total Cache (W3TC) on your site throughly before deploying in live site. Read on further when you find some pages are breaking and want to exclude from the caching.
Why Excluding Specific Pages and Directories?
There are many reasons for excluding specific pages and directories from caching for proper loading. In our cache we have the following situations:
- Work with WooCommerce – the product and cart pages generally breaks with W3TC caching
- Theme showcasing – the sliders will break with the caching and not load properly on mobile devices
- Visual Composer – the blog carousel will not work properly with W3TC
Since the theme we use on this site heavily depends on jQuery, we need to disable the minification of JavaScript for the pages to load correctly. But later we have found W3TC provides an option for excluding the pages and directories with wild card so that they are not cached.
How to Exclude Pages and Directories from Caching in W3 Total Cache?
Login to your WordPress admin panel and navigate to “Performance > Page Cache” section. Scroll down to the “Advanced” section and look for the option “Never cache the following pages”.
Enter the page URLs and directories under the “Never cache the following pages” to exclude them from caching.
How to Enter Page URL and Directories?
The exception supports regular expression. Enter one entires per line, it could be a page URL or the directory. The URLs and the directories are entered as relative URLs to your domain. Below are some of the examples:
- /showcase*
- /shop*
- /demo/
- /post-name/
- /page-url/
Other Possibilities for Excluding Content from Caching
Besides excluding posts, pages and directories there are many other possibilities allowed in W3TC. These options are available in the same “Advanced” section under “Page Caching”.
Excluding Posts with Specified Categories
You can exclude all the posts under specified category by mentioning the category slug in the text box “Never cache pages associated with these categories”. For example, if you have the category named “technology” then just enter the slug as “technology” without leading or trailing slash.
Excluding Posts with Specified Tags
Similar to categories, you can ignore the posts from caching based on the tags. Remember to enter the tag slug without slashes.
Excluding Posts Based on Author
Enter the author names one per line in the box “Never cache pages” to exclude them from caching based on the author.
Exclude Posts Based on Custom Fields
Also you can exclude the pages from caching based on the usage of custom fields on the pages. The format of the entry should be like “custom filed=value” as shown below.
4 Comments
Leave your reply.