wp-memcached icon indicating copy to clipboard operation
wp-memcached copied to clipboard

[Feature request/question] How to disable for a single website in wpmu ?

Open mbautista opened this issue 1 year ago • 5 comments

Hello, Thank you for this module, it rocks :)

Is it possible to disable the cache object on a specific website in a wordpress network ? Is there any constant and/or filter we could use ?

As I could not find it I added a filter in the object-cache.php but I'm not sure if it's required and/or in the right place :

function wp_cache_set( $key, $data, $group = '', $expire = 0 ) {
        global $wp_object_cache;

        if ( defined( 'WP_INSTALLING' ) == false && apply_filters( 'ircf_wp_cache_disabled', false ) == false) {
                return $wp_object_cache->set( $key, $data, $group, $expire );
        } else {
                return $wp_object_cache->delete( $key, $group );
        }
}

Thank you very much :) Mathieu.

mbautista avatar May 13 '24 12:05 mbautista

Disabling the object cache for a specific site in a network is not something that should really be supported IMHO.

The reason is that WordPress has two different levels of cache - Per site cache groups, and global cache groups.

The global cache groups are shared between all sites on the network, and per-site caches are specific to the individual site.

Disabling the cache for a specific site would require keeping the global cache active, as otherwise any changes to network-data would change the DB without updating the cache, causing issues for other sites which retrieve it from the cache instead.

Perhaps the better question is, what's the use-case for disabling it for a specific site? Once that's answered we might be able to suggest ways forward.

dd32 avatar Jun 20 '24 02:06 dd32

Hello @dd32 Thank you for the answer. I agree with you in absolute three is no good reason for disabling the object cache.

But unfortunately I already found 2 plugins that do not work well with object cache :

  • Elementor Post Navigation Widget : the prev/next links are buggy when object cache is activated
  • Oney (woocommerce payment) : the payment method is not displayed when object cache is activated

These plugins are buggy and should be fixed or replaced, but unfortunately it's not always possible quickly, so as a temporary solution I found this filter to disable the object cache for the websites using these plugins on our wp network.

But I agree it's more a hack than a feature, besides without object caching these websites are much more slower :/ Mathieu.

mbautista avatar Jun 20 '24 06:06 mbautista

Same here... Only one WP installation and wp-content/ but multiple databases, and as such, object-cache.php is present, but I want to enable/disable from the environment. Something like WP_MEMCACHE which, if false, disable the plugin?

drzraf avatar Mar 20 '25 01:03 drzraf

Hi @drzraf FYI we are slowly replacing our websites with wp-memcached to redis cache object : redis cache object allows per site configuration and provides a wp-admin interface to configure/enable/purge cache object per site.

EDIT : You also have to replace the service memcached by redis-server in your server config.

mbautista avatar Mar 20 '25 07:03 mbautista

Ok. Anyway the present issue would be likely fixed by #37

drzraf avatar Mar 20 '25 23:03 drzraf