What To Exclude From WooCommerce Cache

What Is Caching?

Caching occurs when a web browser saves a copy of a website’s files on the hard drive in a temporary location for anyone visiting the site. Caching offers huge performance benefits and loading speed improvements because for cached webpages, web browsers only need to load the updated parts of the page and not the entire page

How WooCommerce caching differs from WordPress caching ?

WordPress caching is called Static, that means that the pages and posts rarely change.

WooCommerce on the other hand, is dynamic, where the content changes based on who is looking at the page and when.

In addition, WooCommerce has carts, products, checkouts, payments, and functionality such as resetting passwords, that change for each user during the duration of a session.

Because of its dynamic pages, you will need to exclude certain things in WooCommerce from the cache.

It is very important to make the exclusions we will list below from the cache or your customer will experience several issues such as the following examples:

  • Items appear in a customers shopping cart which they did not add
  • Customers having the ability to see other customers account details including credit card payment information
  • Customers seeing another customers address at checkout.

What To Exclude From WooCommerce Cache

1. Excluding pages from the cache

The following Pages should be excluded from the Cache

  • Cart Page
  • My Account Page
  • Checkout Page
  • Products Page

2. Excluding WooCommerce cookies from the cache

Cookies in WooCommerce help track the products in your customers cart, allow customers to keep can their carts available even when the leave the site.  

Cookie Name
  • woocommerce_cart_hash [Duration = Session]
  • woocommerce_items_in_cart [Duration = Session]
  • wp_woocommerce_session_ [Duration = 2 Days]
  • woocommerce_recently_viewed [Duration = Session]
  • store_notice (notice id) [Duration = Session]

3. Excluding WooCommerce session from the cache

If you also have database caching also called memcache, it is probably a good idea to exclude the following session from the cache

  • _wc_session_

How to Verify That Your WooCommerce Store Works Properly Following Caching ConfigurationOnce you’re happy

Once you are complete with making all the necessary exclusions for WooCommerce Cache, it is now time to test some of the functionality to ensure that everything is working properly. You should perform the following tests:

  • Try logging in as a customer
  • Try resetting your password as a logged in customer
  • Ascertain that your product page loads properly and shows the appropriate products
  • Ascertain that your category pages load properly and display the appropriate products
  • Make a purchase on your website as a guest. You will then need to that the subtotals are correct, the details displayed are correct such address and name and the payment processes properly
  • Make a purchase on your website, logged in as customer. You will also need to ensure the subtotals are correct, the details displayed are correct such address and name and the payment processes properly
  • If you use Coupons in your online store, try using one at checkout and verify if it works as intended and displays the correct discount and the new total