Does anyone here run memcache on multiple sites on the same server?

If so, do you have any weird issues like images and/or CSS from one site “leaking” across into other sites?

I’ve been running Memcache via this method on one specific site. Everything is good, it improved my database call times etc.

Then, when I went to install the same thing on another site on the same server, images and CSS got messed up. Like the CSS from the original site was been pulled into the new site.

I removed the Memcache scripts from the new site and flushed all caches, and everything went back to normal.

Is there a way to avoid this? Any help is appreciated!

I use this Redis Cache plugin which works just as well as Memcache. After you’ve setup the plugin, you just need to add the following to your wp-config.php file.

const WP_CACHE_KEY_SALT = 'some_unique_identifier'; // I use the website name + some random characters as an identifier
const WP_REDIS_CLIENT = 'pecl'; // Make sure we are using the more efficent PECL implementation of REDIS, instead of the one that was written in PHP

The WP_CACHE_KEY_SALT is then added to all of the Redis entries for that website to keep them from conflicting with other sites.

If you’re bent on using Memcache, you will need to find a Memcache plugin that has a similar option you can use.

1 Like

I find that w3 total cache does a great job of cachng without any cross-site bleeding over.
Cloudways even has a recommended configuration for it. I followed their tutorial to the letter and have had great results.

Thanks guys, appreciate the input.

Hey there, did you try implementing the Redis Object Cache? Is more advanced:

@fabiofava No, I haven’t - but it looks like a good way to go. Thanks :slight_smile:

I’m also using W3TC to do full Page Caching and Object Caching, and it works great for multi-server configuration.

However I’m running into a similar issue with CSS/JS caching. I can’t seem to change the folder to a shared EFS directory.

Is it possible to store the CSS/JS into redis or change the folder where cached files are stored?

Styles and scripts are static files themselves and therefore don’t need to be cached.

Are you using w3 to combine and minify? If so, I have found that Autoptimize is more reliable from the standpoint of not breaking scripts or styles when combining them.