Experimental Product Object Caching in WooCommerce 10.5

WooCommerce 10.5 introduces an experimental Product Object Caching feature that improves performance by caching product instances during each request, preventing duplicate product loads from the database.

How It Works

When enabled:

  • wc_get_product() / WC_Product_Factory::get_product() checks an in-memory cache before loading from the datastore
  • Products loaded from the datastore are cached for subsequent calls within the same request
  • Cache is automatically invalidated when products are updated via standard WooCommerce/WordPress APIs
  • The cache is non-persistent (in-memory only, clears between requests)

Enabling the Feature

  1. Navigate to WooCommerce → Settings → Advanced → Features
  2. Enable “Cache Product Objects”

Performance Impact

Performance improvements will vary significantly based on:

  • The extensions active on your site
  • How those extensions interact with products (how many times they load the same product)
  • The types of products being loaded (simple, variable, bundles, subscriptions)

Example benchmarks (with WooCommerce All Products for Subscriptions active):

Product TypeOperationImprovement
Variable ProductView Product Page-160ms to -227ms (~9-12%)
Variable ProductAdd to Cart-235ms to -250ms (~12-13%)
Bundle ProductPlace Order-165ms to -234ms (~6-12%)
Simple ProductPlace Order-22ms to -56ms (~2-6%)

Note: These benchmarks were captured with WooCommerce All Products for Subscriptions enabled, which triggers additional product loading operations. Sites with different extension combinations will see different results – some more, some less.

How can developers tell if they are affected?

The caching implementation uses standard WordPress and WooCommerce hooks for cache invalidation. In most cases, extensions should work without modification. However, there are edge cases to be aware of:

Cache invalidation is triggered by:

  • clean_post_cache action (WordPress post updates/deletions)
  • updated_post_meta, added_post_meta, deleted_post_meta actions
  • woocommerce_updated_product_stock and woocommerce_updated_product_sales actions
  • WooCommerce product datastore save() operations

Potential compatibility considerations:

  1. Direct SQL updates: If your extension updates product data using direct database queries without triggering WordPress meta hooks or calling clean_post_cache(), the cached product will become stale for the remainder of the request.
  2. Repeated product loading: If your extension calls wc_get_product() multiple times for the same product ID within a request, all calls will return clones of the same cached instance. This is the intended behavior and should be transparent to most code.

What action do developers need to take if affected?

This feature is disabled by default, but can be enabled by store owners. Third party developers should test for compatibility.

If you encounter unexpected behavior with this feature enabled, please open an issue with details about which extensions are active.


One response to “Experimental Product Object Caching in WooCommerce 10.5”

  1. You’re only just adding object caching to the product instance now? I’m amazed this wasn’t already in place.

Leave a Reply

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