Using WP Rocket on your WooCommerce site
Everything you need to know about WP Rocket and WooCommerce!
In this Article
WP Rocket detects when you’re using WooCommerce on your WordPress site and does the following:
- Automatically excludes the Cart, Account and Checkout pages, as set in your WooCommerce settings, and the WooCommerce rest API.You won’t see this in the plugin settings, it’s done automatically behind the scenes.
- Automatically optimize the
get_refreshed_fragmentsrequest. Should you notice any issue with your cart widget being pre-filled or showing the wrong number of products, try deactivating this feature.
- When you use WooCommerce’s Geolocate (with page caching support) option, WooCommerce adds a query string like this -
v=42983b05e2f2&- to all URLs. These will be automatically cached.
- WP Rocket has automatic compatibility with Aelia’s Currency Switcher, Prices by Country and Tax Display by Country plugins, and with the WooCommerce Multilingual add-on for WPML.
What are the best settings for WooCommerce?
Since WP Rocket already takes care of the items above, there aren’t any other specific settings you need to configure.
With any site the best settings will depend on which other plugins and theme you are using. WooCommerce has hundreds of related extensions so the combinations are infinite and we can’t state which optimizations will work perfectly in every scenario.
We recommend following these best practices when configuring WP Rocket on your WooCommerce site.
WP Rocket automatically purges the cache when you update content on your site, and that includes adding/editing terms, products and product variations. If you have enabled preload, the products will be preloaded afterwards.
The cache purging will still be triggered if you are using an API to import products.
If you have enabled “Enable stock management at product level”, WooCommerce will automatically update the product during checkout, which in turn triggers WP Rocket to purge the cache for that product and its related pages. This will keep the stock number accurate on the site.
Related to this, we are aware of one issue related to cache purging which slows down the checkout page when a product is in many categories.This can be resolved by deactivating our automatic cache clearing.
Resolving dynamic content issues
Otherwise you could have issues where the wrong content is displayed in the wrong circumstances. This could also affect cart widgets which use PHP instead of AJAX to update the number of items.
WP Rocket cannot change the way that feature has been coded, that's up to the developers of those plugins/features. The only solution in WP Rocket for that scenario is to prevent caching when certain cookies are present.
In some cases, if the content varies according to the value of a cookie, it could be possible to make it compatible using our dynamic/mandatory cookie feature. This is the method used for the Aelia plugin compatibilities mentioned above.
We have some helper plugins to further enhance functionality in specific scenarios:
- Using WP Rocket with YITH WooCommerce Wishlist
- Making WP Rocket work with WooCommerce recently viewed products widget
Optimizing excluded pages
Since key pages like the Cart and Checkout have to be excluded from the cache, but still need to be fast for conversions, optimizing your site and server in general will help:
- Enable object caching (has to be done at the server level)
- Keep the database light with regular cleanings
- Remove any slow plugins/code from your site
- Get the best hosting you can afford
- Make sure plugins aren’t loading unnecessary files on those pages