Goldlilys Media Logo

Installing Memcache for Better Website Performance

Another website accelerator that caches MySQL queries, and PHP executions is called Memcache.

Memcache decreases the load on the server, enabling you to deliver the pages to your end-users more quickly because it doesn’t need to calculate queries from the database anymore, but fetches it from the memory cache instead.

Think of it this way, if you’re trying to remember a particular piece of info with facts coming from different sources, it’s hard to find things if you haven’t written it down somewhere. People easily forget much of their vast knowledge until they remember an idea about that topic.

Memcache works almost like a traditional notebook. It allows the server to store all of the information in one spot, eliminating the need to search the entire database to execute an action because the action is already in the server’s memory.

Steps to add Memcache to your server (mine runs on CentOS) are:

  1. # yum install memcache
  2. Depending on how much RAM your server contains, the amount of memory allocated should be at least ¼ of it. For example, if your server RAM is 4GB, then allocate 1GB of memory for memcache.
  3. Make changes in the config file at /etc/sysconfig/memcached and include these info:

    PORT="11211"

    USER="memcached"

    MAXCONN="1024"

    CACHESIZE="1024"

    OPTIONS="-l 127.0.0.1"
    • CACHESIZE is the allocated memory where 1024 is 1GB.
    • The OPTIONS setting is to make sure memcache only listens to the localhost port in your server to avoid caching unnecessary data.
    • To make your memcache more secure, add this line to your IP tables:
      -A INPUT -p tcp --dport 11211 -j ACCEPT
  4. Once you’ve made changes to the setting, start up memcache by:
    # service memcached start

    # chkconfig memcached on
  5. Hold up, we are not done yet. This is the part that I usually forget when installing memcache. We now need to install the Memcache PECL Extension for PHP.
    # pecl install memcache
  6. Make changes to your php.ini at /etc/php.ini or /usr/local/lib/php.ini and add these info:
    [memcache]

    extension=memcache.so

    memcache.hash_strategy=consistent
  7. Restart Apache to apply the changes to your server: # /etc/init.d/httpd restart
  8. To verify memcache is working: # ps aux | grep memcached

To add memcache to Drupal:

  1. Put site to offline mode.
  2. Drush and install memcache Memcache.
  3. Go to your site’s settings.php and add:

    $conf['cache_backends'][] = 'sites/all/modules/memcache/memcache.inc';

    $conf['cache_default_class'] = 'MemCacheDrupal';

    $conf['memcache_key_prefix'] = 'something_unique';
  4. Save, enable the memcache module and put your site back online.

To add memcache to WordPress:

  1. Download http://wordpress.org/plugins/memcached/installation/.
  2. Copy object-cache.php to /wp-content directory.

These should be it for both Drupal and WordPress. Watch your websites load much faster than before.

fgo
Author Bio

Frances Naty Go, Founder of Goldlilys Media, transforms websites into strategic masterpieces for museums, nonprofits, health & wellness brands, higher education, life sciences, travel companies, personal brands and small businesses. With a Computer Science degree from UC San Diego, she specializes in creating digital experiences that educate, engage, and inspire action. Ready to make your digital presence unforgettable?

Categories: * * *
15 Warning Signs Your Website Is Holding You Back Cover

15 Warning Signs Your Website Is Holding You Back

Small website issues don’t look dramatic.
They quietly cost you trust, traffic, and action.

This checklist helps you spot what visitors feel, but never say.
Still Using Wix or Squarespace? That Might Be Costing You More Than You Think Cover

Still Using Wix or Squarespace? That Might Be Costing You More Than You Think

Template platforms feel easy at first.
Growth is where the limits show up.

This guide helps you see whether your website still fits where you’re headed.

Related Articles

Imagine your website as amasterpiece

Sign up for our newsletter and discover how we build websites that spark curiosity, fuel creativity, and deepen connection.
Frances on her cellphone looking right and smiling
performance optimization
create a website masterpiece
Frances Go standing by the Prado with a big smile holding a Michelangelo maroon book and artworks behind her

Reach Audiences Anywhere

Book a free call to share your vision, explore solutions, and start turning your ideas into a successful reality!
© 2026 Goldlilys Media® LLC. All rights reserved. | Do Not Sell | Built with local talent and ❤
Still Using Wix or Squarespace? That Might Be Costing You More Than You Think Cover

Is your platform limiting your growth?

A short guide to help you decide whether your website still fits where you’re headed.
15 Warning Signs Your Website Is Holding You Back Cover

Spot the issues before they cost you

A quick checklist to help you see what might be quietly blocking trust, traffic, or action.

Wait! Before you go...

Not ready to commit yet?
I get it.

Get my free guide:

"15 Warning Signs Your Website Is Holding You Back"