WooCommerce product attribute update cache invalidation scope
0 reputation · 26 May 2023, 21:26 UTC
The goal is to have product attribute changes (price, stock, custom attributes) reflected on the front end without manual cache clearing, relying on WooCommerce's documented caching layer: WC_Cache, WordPress transients, and the woocommerce_clear_all_cache hook.
The uncertainty is which core update pathways actually trigger invalidation. WC_Cache::get returns stored values without an obvious check against dependent product meta changes, and woocommerce_clear_all_cache does not appear to fire on every update path. Behavior also differs between the default object cache and external backends such as Redis or Memcached, and third-party caching plugins may override core hooks, so the invalidation boundary is unclear. Concurrent admin edits raise the additional possibility of cache key collisions serving unrelated product data.
Is woocommerce_clear_all_cache triggered automatically for all attribute and price update pathways, or only some? Does WC_Cache::get perform any validation against product meta changes before returning a cached value? Which of these behaviors should be verified against a specific WooCommerce version before relying on automatic invalidation?