Skip to content
CartPops Docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Caching

Settings to check when a caching plugin, host cache, or CDN makes the cart drawer show old items or stop responding.

CartPops loads the cart live from your store. Page caching, object caching, and CDN rules can interfere when they store something that is different for every visitor. This page lists what to leave uncached and what to try when the drawer shows a stale cart.

How CartPops handles cached pages

The cart drawer is part of the page HTML, so a full-page cache can store it with one visitor’s cart inside. CartPops guards against this when the page loads:

  1. It compares the cart in the page with WooCommerce’s woocommerce_items_in_cart and woocommerce_cart_hash cookies.
  2. If the two do not match, or the cookies are missing or unreadable, it loads the real cart from WooCommerce and updates the drawer.
  3. Cart actions such as removing an item or applying a coupon always go to the server. They are never answered from the page.

Cart requests use two groups of REST routes:

  • /wp-json/wc/store/v1/ is the WooCommerce Store API. CartPops reads and changes the cart through it.
  • /wp-json/cartpops/v1/ holds CartPops’ own routes, such as drawer data, coupons, and recommendations.

CartPops marks the responses that depend on the visitor’s session with Cache-Control: no-store, no-cache, must-revalidate, private and Vary: Cookie. A cache that respects those headers will not store them. The one exception is the Pro Bundle Builder configuration route, which is the same for every visitor.

What to exclude from caches

Check that your page cache and CDN do not store the following:

  • Any URL that contains /wp-json/wc/store/ or /wp-json/cartpops/.
  • If your site uses plain permalinks, the same routes appear as ?rest_route=/wc/store/ and ?rest_route=/cartpops/.
  • /wp-admin/admin-ajax.php. CartPops uses it to refresh the REST nonce for logged-in customers.
  • The WooCommerce Cart, Checkout, and My account pages. Most caching plugins exclude these already.
  • WooCommerce AJAX URLs that contain wc-ajax=.

Also check that nothing removes or ignores the woocommerce_items_in_cart and woocommerce_cart_hash cookies. WooCommerce sets them. CartPops reads them to tell whether a cached page matches the visitor’s cart. Many hosts and caching plugins already skip the page cache for visitors who have these cookies. If yours does not, add them to the cookie exclusion list.

CartPops does not keep cart or session data in the WordPress object cache, so no object cache exclusion is needed for it. WooCommerce manages its own session cache.

The drawer shows an old cart after a page load

If cached pages still show the wrong cart contents after you have set up the exclusions above:

  1. Go to WooCommerce > CartPops > Advanced.
  2. On the General tab, find Performance.
  3. Turn on Refresh cart data on page load.
  4. Save, then clear your page cache.

This setting asks WooCommerce for fresh cart data on every page load, even when the cookies say the cached cart is correct. It adds one request per page, so use it only if you need it.

The drawer or launcher does not respond

CartPops loads its storefront code as WordPress script modules (type="module") from the plugin’s assets/build/ folder. Some optimization plugins combine, delay, or remove scripts, and can break modules.

If the launcher is visible but nothing happens when you click it:

  1. In your optimization or caching plugin, turn off the delay-JavaScript and combine-JavaScript options. Make sure jQuery and WooCommerce’s add-to-cart script are not delayed either, because CartPops listens for WooCommerce’s classic add-to-cart event through jQuery.
  2. Clear all caches and test again.
  3. If that fixes it, turn the options back on one at a time. Then exclude the CartPops files from the option that caused the problem.

Cart Fragments

CartPops does not depend on the WooCommerce Cart Fragments script. After a classic AJAX add to cart, CartPops adds its own cart data to WooCommerce’s response, and uses it to open the drawer right away. When that data is missing, for example because the response was cached or the fragments are turned off, CartPops reads the cart through the Store API instead.

Was this page helpful?