X

Enabling Memcached in Magento

To help increase the speed of Magento page loads as much as possible, it is recommended to use the Memcached support built within Magento. Memcached is a high-performance memory object caching system that is designed to speed page loads on dynamic content websites. Magento supports Memcached for caching many objects, but it is not enabled by default and will require some simple changes to your configured local.xml file to use.

First, be sure that Memcached is installed and running on your server. It by default listens on port 11211. A ‘netstat’ will verify that you do indeed have a Memcached listening socket on port 11211 indicating that is it running. Configuring Memcached to listen on localhost is recommended as it would be a security risk allowing any external sources access Memcached directly if it were to be listening on an external ip that wasn’t firewalled.

You also need to be sure that Memcached support is loaded into PHP. A view on a phpinfo() page can verify this, just look for the ‘Memcache’ block in the phpinfo and be sure it is ‘enabled’.

To enable Memcached within Magento, you will need to add the following block of code to your app/etc/local.xml file:

Open the file and find the following line of code (usually this is also the end of the file):

 </config>

Right before this line add the following lines:

<cache>
<backend>
memcached</backend>
<!-- apc / memcached / empty=file -->
<memcached>
<!-- memcached cache backend related config -->
<servers>
<!-- any number of server nodes can be included -->
<server>
<host>
<![CDATA[127.0.0.1]]>
</host>
<port>
<![CDATA[11211]]>
</port>
<persistent>
<![CDATA[1]]>
</persistent>
</server>
</servers>
<compression>
<![CDATA[0]]>
</compression>
<cache_dir>
<![CDATA[]]>
</cache_dir>
<hashed_directory_level>
<![CDATA[]]>
</hashed_directory_level>
<hashed_directory_umask>
<![CDATA[]]>
</hashed_directory_umask>
<file_name_prefix>
<![CDATA[]]>
</file_name_prefix>
</memcached>
</cache>

After that save the file. The following screenshot shows how to edit the file via the cPanel File Manager -> Code Editor Tool:

That’s it – your Magento application is now correctly configured. From now on the e-commerce app will use Memcached to cache certain API calls, database calls and objects.

Comments

comments

Loading Likes...
Kazi S: XeonBD, Suite 2A, House 231, Road 06, Mohammadi Housing Limited, Mohammadpur, Dhaka 1207, Bangladesh Web: http://www.xeonbd.com | Blog: https://blog.xeonbd.com | Telephone: +88-02-8101735 | Fax: +88-02-8101736 Sales HotLine: +88 019 77XEONBD (936623)
Related Post
Leave a Comment

In order to give you the best experience, our website uses cookies.