WordPress has thousands of free and premium plugins. But there are limited plugins that will work on all themes without any compatibility issues. W3 Total Cache and WooCommerce are two such popular plugins that work on most of the themes. The problem is that they two will not work smoothly when installed on the same WordPress site. It is for sure W3 Total Cache settings will break the WooCommerce product pages and affect your online sales. Most of the bloggers use WooCommerce for smaller portion of their site and consider caching the majority of the site with W3 Total Cache. In such case, here are the settings you should make to ensure WooCommerce work with W3 Total Cache.
How to Make WooCommerce Work with W3 Total Cache?
Ensure to add the following settings in W3 Total Cache plugin:
- Ignore WooCommerce pages from caching
- Add mfunc in ignored comments stems for HTML minification
- Disable JS minification or use default blocking
- Add all WooCommerce pages for not minifying
- Add _wc_session_ in ignored query stems with DB caching
Let us discuss each option in detail.
1. Exclude WooCommerce Pages from Caching
In our earlier article, we have explained how to exclude pages from caching in W3TC settings. If you see, W3TC breaks your product pages then consider ignore them from caching. Navigate to “Performance > Page Cache” settings and scroll down to “Advanced” section. You will see a text box for “Never cache the following pages:”. Enter all your WooCommerce pages here for excluding from caching. You can use regular expressions and wildcard like shop*, cart, checkout and product* to exclude all WooCommerce related pages.
2. HTML & XML Minify Settings
Actually you can cache the product pages because in most cases minification settings is the one will break your site. Simply you can disable minification settings, but without minification you will see many page speed related errors in Google PageSpeed tool. So, you have no other option to enable minify settings in W3TC or use additional plugin for this purpose. When you enable minify settings in W3TC, navigate to “Performance > Minify” menu and add “mfunc” in the “Ignored comment stems” text box under “HTML & XML” section. This will ensure WooCommerce page will work properly with W3TC.
3. Disable JS Minification
4. Exclude Pages from Minifying
This is another option that you can completely exclude all WooCommerce pages from minifying similar to excluding from caching. Navigate to “Performance > Minify” menu and go to “Advanced” section. Enter WooCommerce related pages under “Never minify the following pages” text box. You can enter the pages like shop, cart, checkout and product* for excluding.
5. Add _wc_session_ in DB Caching
Generally DB caching and object caching tend to create many other problems than speeding up your site. When you look at the “Performance > Install” menu, W3TC makes these two settings optional. If you still enable WB caching then ensure to add “_wc_session_” under “Ignored query stems” text box in DB cache settings.
It will be a daunting task to make WooCommerce pages work smoothly with W3 Total Cache plugin. As mentioned, this makes sense when you have smaller shop attached to a bigger blog or content site. Otherwise you can look for alternate plugins like Autoptimize or Fast Velocity Minify to minify your pages. You can also combine one of these minify plugins with W3TC and disable native minify option in W3TC.