Skip to content

Caching & Performance

Dino Discounts is built with aggressive caching internally, but it also needs your full-page caching plugin configured correctly.

The plugin handles its own performance optimisation:

Every time the cart is evaluated, the engine creates a fingerprint (hash) of the cart contents, quantities, customer data, and applied coupons. If the fingerprint hasn’t changed, the previous result is reused — no recalculation.

Published discounts are read from the database once per request and held in memory, and cart evaluation results are cached for about a minute in WordPress transients. Publishing clears both automatically.

Zone definitions (country → zone mappings) are cached in a transient. Saving zones, or editing a WooCommerce shipping zone, clears it.

You don’t need to configure any of this — it works automatically.

If you use a full-page caching plugin, URL exclusions alone are not enough. On WP-Optimize, for example, excluding only /cart/ and /checkout/ still breaks the storefront, because /?add-to-cart=… is treated as a homepage request and served from the cached homepage HTML — so the WooCommerce session cookie is never set and the cart stays empty for every guest.

To work end-to-end, the cache plugin needs three sets of exclusions:

  • /cart — the cart page
  • /checkout — the checkout page
  • /my-account — the customer account area

Configure each in your cache plugin’s URL / page exclusion list:

  • WP Rocket — Add to “Never Cache (URLs)”
  • WP-Optimize — Add to “URLs to exclude from caching”
  • WP Super Cache — Add to “Rejected URI Strings”
  • W3 Total Cache — Add to “Never Cache” pages
  • LiteSpeed Cache — Add to “Do Not Cache URIs”
  • SiteGround Optimizer — Add to cache exclusion list

If any of these cookies is set, the cache plugin must serve a fresh (uncached) page rather than the cached HTML — otherwise the cart page reflects the wrong session:

  • wp_woocommerce_session_ (prefix — the per-customer WC session cookie)
  • woocommerce_items_in_cart
  • woocommerce_cart_hash
  • wordpress_logged_in_ (prefix — present for any logged-in user)

Configure these in the “Never cache pages with these cookies” / “Bypass cache on cookie” list in your cache plugin.

3. Query variables that should never be cached

Section titled “3. Query variables that should never be cached”

WooCommerce’s add-to-cart / coupon-apply flow rides on query parameters that must NOT be cached, or the action is silently ignored:

  • add-to-cart
  • remove_item
  • undo_item
  • applied_coupon
  • removed_coupon

Configure these as “Never cache URLs containing these query strings” / “Exclude query strings from caching”.

Full-page caching serves a saved copy of the page to every visitor. With the wrong configuration:

  • Discounts appear to not apply (the storefront shows a cached pre-discount cart)
  • Wrong discount amounts (a stale cart hash is served to a different session)
  • Other customers’ cart contents may be visible in extreme cases
  • “Add to cart” silently does nothing (the add-to-cart query is cached as part of the homepage URL)

Purging the page cache when discounts change

Section titled “Purging the page cache when discounts change”

When you publish a rule change (or any setting that affects discount evaluation), Dino clears its own caches and fires the dino_discounts_cache_flush action. It also tells your page cache to drop the product pages the change affects, or the whole cache when the rule applies store-wide:

  • WP Rocket, WP Super Cache, LiteSpeed Cache, W3 Total Cache and WP-Optimize are purged automatically.
  • SiteGround Optimizer, Breeze and Hummingbird are not. Dino can’t clear a single product page in them, so the rule editor’s Product page block warns you to clear the cache yourself after publishing.
  • A CDN in front of your store (Cloudflare, Fastly, Bunny CDN) is never purged by Dino. When one is detected, the Product page block reminds you to set the CDN to purge on WordPress cache events.
  • A scheduled promo shown on the product page is not purged when its schedule starts or ends. The When does it apply? section warns about this.

For any other page cache, or a custom snippet on your site, subscribe to the hook and clear the cache yourself:

add_action( 'dino_discounts_cache_flush', function () {
// Replace with your cache plugin's purge call.
if ( function_exists( 'my_cache_purge_all' ) ) {
my_cache_purge_all();
}
} );

Without a purge, a published rule change won’t reach shoppers on cached product pages until those pages expire.

Dino Discounts works fine with object caching (Redis, Memcached). WordPress transients are stored in the object cache when available, which makes discount and zone loading faster.

No special configuration is needed.

CDNs (Cloudflare, Fastly, etc.) that cache HTML pages need the same cart/checkout exclusion as full-page caching plugins. Most CDN setups already exclude these pages, but verify yours does.

API calls (/wp-json/dino-discounts/v1/*) should never be cached by your CDN. Most CDN configurations exclude /wp-json/ by default.

WooCommerce is a trademark of Automattic, Inc. WordPress is a trademark of the WordPress Foundation. Dino Discounts is not affiliated with or endorsed by Automattic or the WordPress Foundation.

Contact · Report a bug