[wp-trac] [WordPress Trac] #63070: Flushing object cache removes all transients

WordPress Trac noreply at wordpress.org
Fri Mar 7 01:10:28 UTC 2025


#63070: Flushing object cache removes all transients
-------------------------+-----------------------------
 Reporter:  deploysk     |      Owner:  (none)
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  General      |    Version:
 Severity:  normal       |   Keywords:
  Focuses:  performance  |
-------------------------+-----------------------------
 Flushing the object cache by calling wp_cache_flush() removes all stored
 transients.

 **Description**
 Transients are often used by plugins to store results of performance
 expensive tasks. Transients do have an expiration date and usually are
 closely managed by plugins to only invalidate when necessary.

 When object cache is active, WordPress saves all transients in object
 cache only.

 Object cache is often flushed by plugins on routine tasks as updating
 posts (e.g. WooCommerce products).
 This also removes all stored transients.

 This often results in huge performance setbacks as all transients need to
 get re-built, even though they did not reach their expiration date.

 One example is WordPress saving the results of the last check for updates
 for all plugins as a site transient. Loading the current version from an
 external source for tens of plugins can take several seconds and is only
 performed once per day.
 However, if users update any WooCommerce products on this site, cache gets
 flushed along with all transients. WordPress will now load the current
 versions again. If the page contents are updated regularly during the day,
 the site will make perform this expensive task over and over again,
 ultimately beating the main purpose of an object cache, making the page
 load slower.

 **Expected Behavior**
 There should be better expiry management in place for transients to not
 remove all of them during each object cache flush.

 **Actual Behavior**
 All transients are deleted when flushing the object cache.

 **Steps to Reproduce**
 1. Activate an object cache solution (e.g. Redis Object Cache).
 1. Create any transients by loading the page.
 3. Modify contents to trigger cache flush (e.g. update a WooCommerce
 product).
 4. Verify, if the transients were removed (e.g. by counting them with
 redis-cli --scan --pattern "wp:transient:*" | wc -l)

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63070>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list