How to Make WooCommerce Work with W3 Total Cache?

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:

  1. Ignore WooCommerce pages from caching
  2. Add mfunc in ignored comments stems for HTML minification
  3. Disable JS minification or use default blocking
  4. Add all WooCommerce pages for not minifying
  5. 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.

Exclude WooCommerce Pages from Caching
Exclude WooCommerce Pages from Caching

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.

HTML and XML Minify for WooCommerce
HTML and XML Minify for WooCommerce

3. Disable JS Minification

WooCommerce scripts when minified and combined will break the product pages. Also the cart and checkout pages may not work as intended. In this case, you can disable JS minify in W3TC settings. If you still want to enable JS minify, ensure to choose “Default (blocking)” options. This will result in “Eliminate render blocking JavaScript and CSS” error in Google PageSpeed Insights tool. But this should be fine, if you have good looking and functional pages loading faster.

JS Minify Settings for WooCommerce
JS Minify Settings for WooCommerce

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.

Exclude Pages from W3TC Minify
Exclude Pages from W3TC Minify

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.

DB Cache Settings for WooCommerce
DB Cache Settings for WooCommerce

Conclusion

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.

Editorial Staff at WebNots are team members who love to build websites and share the learning with webmasters community. Follow us on Facebook and Twitter.

3 thoughts on “How to Make WooCommerce Work with W3 Total Cache?”

Leave your response.

  1. This is really helpful for setting up W3 Total Cache! I noticed that W3 Total Cache automatically added _wc_session_ in the DB Caching. Maybe this is a update in W3 Total Cache or someone before me added this. Anyways, thanks again!

    Reply
  2. Wow! This was the most HELPFUL article. Thank you for putting this in an easy to understand way. I’m really bad at tech and was able to follow this so thank you! I think I got Woocommerce working on my page now :)

    Reply

Leave a Comment