• Skip to primary navigation
  • Skip to main content
  • Skip to footer
WP Minder logo

WP Minder

  • WordPress Care Plans
    • Basic Care Plan
    • Advanced Care Plan
    • Premium Care Plan
    • Care Plans for Agencies
    • Compare Care Plans
  • FAQ
  • Blog
  • About
  • Contact
  • Find A Care Plan
  • Log In

Excluding WooCommerce Pages from Caching

May 5, 2022 by Debbie Campbell Leave a Comment

If you run a WooCommerce shop and you’re using a caching plugin on your website – or your host is providing one as a service, like Varnish – make sure caching is disabled for key WooCommerce pages and cookies.

What is Caching?

Caching is ‘saving’ website information and content in the user’s browser on their first visit and displaying that saved page in the future rather than having to pull it from the server. It allows for faster page loading than if the page had to be ‘rebuilt’ from scratch each time the user views it.

But caching has its drawbacks, as you probably know from being told to ‘clear your cache’ to try to fix any website issue. Caching impacts on WooCommerce can include:

  • Users seeing old versions of the checkout page when they try to finish an order
  • Users seeing other users’ carts or finding strange items in their carts
  • Users seeing other users’ account info
  • Issues with WooCommerce checkout pages never loading

WooCommerce logoThese problems can cause your customers to trust your site less as well as privacy issues. But it can be fixed easily by excluding dynamic pages from the cache. Note: some caching plugins automatically exclude cart and checkout pages for certain ecommerce plugins. Check your plugin’s documentation.

How to Disable Caching for WooCommerce in WP Rocket

WP Rocket is a popular commercial caching plugin for WordPress. It does automatically exclude the Cart, Checkout and Account pages automatically, but there are a few more things you need to do.

1. Go to the WP Rocket settings, Advanced Rules.

2. In the Never Cache Cookies section, add the following lines:

woocommerce_cart_hash
woocommerce_items_in_cart
wp_woocommerce_session_
woocommerce_recently_viewed
store_notice[noticeid]

3. Save the changes.

Cookies help track products in carts and power the ‘recently viewed’ widget – they need to stay dynamic as they change a lot.

This process should be simliar for different caching plugins.

How to Disable Caching for WooCommerce in Varnish

Varnish is a server-side tool that speeds up website loading as well as providing security protection. Part of its job is to temporarily store the content of your web pages (a cache), which will be served up when a user requests them rather than making a call on your host server (just like the plugin-based caches).

If you have access to the server settings, you can add the following WooCommerce exclusions to Varnish.

Pages/URLs:

\?add-to-cart=
\^/(cart|my-account/*|checkout|wc-api/*|addons|logout|lost-password|product/*|wp-admin|wp-login)
\/checkout/
\/my-account/

Cookies:

woocommerce_cart_hash
woocommerce_items_in_cart
wp_woocommerce_session_
woocommerce_recently_viewed
store_notice[notice id]

Share this post...

Filed Under: Ecommerce Tagged With: ecommerce, woocommerce

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Previous Post
Next Post

Footer

iubenda Certified Bronze Partner
Cloudways Agency Partner

From the Blog

  • WordPress 6.0 Due Out Today

  • The Latest US Privacy Law News

  • The Risky Business of Displaying Only the Best Reviews on Your Website

Latest WordPress Security Alerts

  • Analyzing a WooCommerce Credit Card Skimmer
    on May 19, 2022
  • X-Cart Skimmer with DOM-based Obfuscation
    on May 17, 2022
  • Massive WordPress JavaScript Injection Campaign Redirects to Ads 
    on May 11, 2022
© Copyright 2022 WP Minder · All Rights Reserved · Privacy · Terms · Affiliates
We use cookies on our site to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept," you consent to the use of ALL cookies.
.
Manage Cookies >Accept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT
Powered by CookieYes Logo
WP Minder logo
  • WordPress Care Plans
    • Basic Care Plan
    • Advanced Care Plan
    • Premium Care Plan
    • Care Plans for Agencies
    • Compare Care Plans
  • FAQ
  • Blog
  • About
  • Contact
  • Find A Care Plan
  • Log In