Support » Plugin: W3 Total Cache » Suggested changes to object caching and transients

  • Resolved archon810

    (@archon810)



    Hi Frederick,

    I have two suggestions, which I’d love to discuss here.

    1. IMO, if object caching is on, transients set without expiration (set_transient with no expiration parameter) shouldn’t expire after the same time as “Default lifetime of cache objects” which is I think 3 minutes by default. This is completely counter-intuitive – transients aren’t like other objects and by default when object caching is turned off get written to the database permanently. So a transient without an expiration should stay in the cache indefinitely, at least until evicted by memcached/APC itself.

    2. W3TC should support another type of object groups called Excluded groups. For example, if “transient” is added to non-persistent groups right now, none of the transients survive at all. There’s no way to make certain groups basically disregard W3TC policies and go to the MySQL database instead where they can be stored permanently. For transients, it especially makes sense, since we could be relying on them for storing things like locks to prevent multiple processing from doing the same thing over and over or too frequently.

    I hope you can consider my suggestions, and I welcome any discussion.

    https://wordpress.org/plugins/w3-total-cache/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Frederick Townes

    (@fredericktownes)

    wp_cache_set($id, $data, $group = 'default', $expire = 0) doesn’t call w3-total-cache/lib/W3/Cache/Apc.php but lib/ObjectCache.php has no problems with parameters there, but $group = '0' should be replaced with $group = '‘ in all /Cache/* files to avoid problems with Object cache. that will be fixed in next release.

    Sure you’re replying to the right post, Frederick?

    Hi Frederick, any news on when the next release will come out? Will it address the issue discussed in this thread? Thanks.

    Radhe

    (@pulser1983)

    Is this issue resolved. Please let me know.

    Hi all, this ‘bug’ has not been addressed yet I suppose because I’m currently struggeling with a set_transient() that I use in a plugin to store a remote xml response for a day. Setting the transient simply fails silently. Had a hard time with this — even lost some hairs 😉 — before I finally figured out is was the W3TC object caching 🙁

    Hope this can be addressed soon!

    For what it’s worth, I found a workaround mentioned by Andy Adams on http://wordpress.stackexchange.com/questions/108287/trouble-with-transient-api-when-w3tc-is-activated where he proposes to disable object caching temporarily like this:

    // We need to turn off the object cache temporarily while we deal with transients,
    // as the W3 Total Cache conflicts with our work
    global $_wp_using_ext_object_cache;
    
    $_wp_using_ext_object_cache_previous = $_wp_using_ext_object_cache;
    $_wp_using_ext_object_cache = false;
    
    // ...do some work with transients here...
    
    $_wp_using_ext_object_cache = $_wp_using_ext_object_cache_previous;

    I’ll be testing this method and report back here 🙂

    UPDATE: the work-around seems to work.

    QUESTION: instead of disabling the object cache mechanism at the point of setting and retrieving transients — which is a bit sad really — would it maybe wiser to use wp_cache_set() when W3TC Object Caching is activated?

    Plugin Author Frederick Townes

    (@fredericktownes)

    1. Is implemented by fragment cache.
    2. Is not possible, WP doesn’t provide an opportunity to get to call the database when object cache is enabled. WP’s function set_transient contains:

    if ( wp_using_ext_object_cache() ) {
            $result = wp_cache_set( $transient, $value, 'transient', $expiration );
        } else {
       // write to db

    Hi Frederick,

    1. Is implemented by fragment cache.

    Are you saying it’s better to use https://wordpress.org/plugins/wp-fragment-cache/ instead of W3TC Object Caching or in combination with it?

    2. Is not possible, WP doesn’t provide an opportunity to get to call the database when object cache is enabled.

    So I gather wp_cache_set() is already being used when $_wp_using_ext_object_cache = true then?

    Any ETA on a fix like https://wordpress.org/support/topic/self-diagnosed-and-fixed-w3-total-cache-bug-in-faulty-object-caching being applied to W3TC?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Suggested changes to object caching and transients’ is closed to new replies.