Skip Navigation
Updated
September 13, 2019

You can enable Memcache for your WPML multilingual site and improve its speed and performance.

Multilingual websites often heavily rely on database queries, at least for the time being. Using Memcached can significantly increase the site’s performance by replacing WordPress’s standard, non-persistent cache with a persistent one.

How to use the Memcached plugin on your server

SiteGround hosting service provides the SG Optimizer plugin for their clients. Although this plugin doesn’t work on other hosting providers, you can still use one of its components and configure it for your site.

The only requirements are that your server supports Memcached and the PHP extension is installed.

Installation

Download the following file from the SG Optimizer plugin: https://plugins.svn.wordpress.org/sg-cachepress/trunk/templates/memcached.tpl

Rename it to object-cache.php and upload it to your wp-content folder.

Configuration

SiteGround automatically configures the correct host and port using the SG Optimizer plugin. However, you will need to edit the object-cache.php file and do this manually. 

Look for the constructor in object-cache.php to set your $memcached_servers correctly:

Constructor in object-cache.php
$memcached_servers = array(
				'default' => array(
				'@changedefaults@'
		)
);

Change @changedefaults@ to your server port. Your hosting provider will give you those details.

For example, your final configuration may look something like the following.

Final configuration example
$memcached_servers = array(
				'default' => array(
				'memcached:11211'
		)
);

That’s it! After this implementation, your object cache will be persistent. This means any subsequent page requests will reuse cached data, significantly boosting your WPML and WordPress site performance.

Debugging

For debugging purposes, you can add the following snippet to the functions.php file in your theme and it’ll display information about Memcached activity:

Debugging
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
	add_action( 'wp_footer', function() {
		$GLOBALS['wp_object_cache' )->stats();
	} );
}