Speeding up Magento with Memcached Opcache
This article was posted in: Web Hosting
This article will explain how to enable the Memcached PHP extension with Magento to take advantage of the memcached RAM based caching system. Before carrying out this work, please check with us to ensure memcached is installed on your server.
NOTE : Memcached is essentially a shared service, and so any information placed within it is potentially accessible from all customers on the same server. This is why we don't run it on our shared hosting platforms. We recommend you use Memcached only on your own managed VPS. Only Opcache is recommended on our shared hosting services.
There is often a little confusion around the way in which memcached works. Memcached is actually a service, which runs on the server in the background. The PHP extension memcached (with the same name, which is confusing) makes the memcache class (with it's various methods and properties) available to PHP, so that web developers can easily access the functionality provided by the Memcached service.
Provided the memcached service is installed and running, and the memcached PHP extension are installed, then you can modify your Magento installation to make use of memcached as a fast caching system. This is an advanced task and so we will assume you are comfortable with editing files within your website.
Enabling Opcache and Memcached in PHP
In cPanel, click on Software > Select PHP Version, and then enable the opcache and memcached (not memcache) extensions by ticking the required boxes. Click Save!
The other extensions will differ depending on your existing configuration. Note - Do NOT use the apc extension with PHP 5.4 or above, as it's not supported!
Create a new file to hold the settings
Instead of adding the settings for memcached into the main configuration file for magento (usually /app/etc/local.xml), it is better to make a separate file that you can then rename quickly to disable memcached if required.
Create the file
with the following contents:
Save the changes - that's it! If you have installed the memcached service yourself on a different port other than 11211, then you will need to modify the above block accordingly.