Setting up Memcached on your VPS

Modified on Tue, 18 Jan 2022 at 06:25 PM

All VPS packages at Savvii are equipped with memcached. Memcached is an object caching system that, for example, can cache the results of database queries. The caching of objects is especially useful when your site is not able to cache complete pages because you have a lot of dynamic content (such as webshops) or you use sessions in PHP.


To benefit from these advantages you need to activate Memchached via a plugin on your WordPress site. W3 Total Cache and Memcached Redux are the most common plugins for this. Memcached Redux is a small, light plugin that only does object-caching via Memcached. The heavier plugin W3 Total Cache has several forms of caching and although it requires more steps to set everything up properly, this can also contribute to an even faster site.


Make sure you don't install and configure both plugins to use Memcached for object caching! The plugins will then get in each other's way.

 

Memcached Redux 

The installation consists of 3 steps: 

1. Install the Memcached Redux plugin 

2. Move the wp-content/plugins/memcached-redux/object-cache.php file to wp-content/object-cache.php . Note: do not copy the file, but actually move it!

3. Add the following lines to wp-config.php after defining DB_NAME but before loading wp-settings.php:

// Cache prefix for memcached
define('WP_CACHE_KEY_SALT', md5(DB_NAME . __FILE__));
Text


Moving object-cache.php can be done via sFTP. 


W3 Total Cache 

The installation and configuration of W3 Total Cache is a bit more difficult: 

1. Install the W3 Total Cache plugin. 

2. Go to the plugin by clicking on 'Perfomance' at the top or in the menu on the left and click on 'General Settings'. 

3. Under 'Page Cache' set 'Page Cache Method' to 'Memcached'. 

4. Uncheck the box under 'Database Cache'. 

5. Under 'Object Cache', tick the box and under 'Object Cache Method', select 'Memcached'. 

6. Go to 'Fragment Cache' and set it to 'MemCached'. 

7. Click on 'Save Settings & Purge Caches'. 


If you enable Minify or other caches, please also select Memcached. Do not enable Database Cache if you use Object Cache, this will make your site slower.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article