1. Home
  2. Websites
  3. How do I use Memcached with WordPress?

How do I use Memcached with WordPress?

Den här artikeln finns även på svSvenska

WP-FFPC haven’t been updated in several years. But at the moment we don’t have any other plugin to recommend and it still works fine. Just be aware that it might stop working at any time if you choose to use it.

Imagine that you have been building your website in WordPress, you got all the pages ready, contact forms, images and plugins that you need to create an informative and selling website for your company.

When you launch the website and try to load it, you realize it takes several seconds before it has finished loading. For how long will you wait before giving up and going somewhere else because this site loads slowly?

We will walk you through how you can optimize your WordPress site using Memcached that is included with all of our web hosting accounts.

How do we meassure?


In our meassurements we mainly use the DevTools that is part of Google Chrome. We will try optimize so that the load time of the pages will be under 100ms if you are using a fast connection. We will turn off the browser cache by clicking Disable Cache in the DevTools so that it doesn’t interfere with the results.
DevTools is activated by right clicking somewhere on the page in Chrome and then clicking Inspect.nge PHP version you also need to check that both OPCache and Memcached are activated, click Save at the bottom when you are done. Check that your website is working and that you do not get any errors, otherwise you might have to change back to the PHP version you were using


Limitations within our tests

We will only account for that the HTML document itself is optimized. There are many more things you can do to optimize your website. For example minimizing CSS, Javascript, images, CDN among other things but this will not be covered by this guide.

We will also only use Chrome DevTools to do the measurements and we will set the cache for visitors only, not for logged in users. The test will be performed on:

40 posts, 19 pages, 30 comments

As with all cache plugins there are some pros and cons. We have chosen to use the plugin WP-FFPC, but during testing we noticed that WooCommerce won’t be automatically excluded. Therefore we recommend not to use WP-FFPC together with WooCommerce at this time.

PHP version, extensions and settings

The very first thing to do is to check if we are using the latest version of PHP, or at the very least PHP 7.0 and that the modules OPCache and Memcached are activated from within cPanel.

PHP 7.x is almost twice as fast than PHP 5.6 that is about three times faster than PHP 5.3 so it matters. We strongly recommend that you upgrade to at least PHP 7.0 if you are not using it already and if your website supports it. We have a guide here that will walk you through how to change PHP version.

Select PHP modules

On the same page as where you change PHP version you also need to check that both OPCache and Memcached are activated. Check that your website is working and that you do not get any errors, otherwise you might have to change back to the PHP version you were using earlier.

Memcached plugin and settings

WP-FFPC - search, install, activate

Install the WP-FFPC plugin via WordPress admin and activate it. It requires a few final touches before it works as needed.

Configure WP-FFPC

Click on Settings in WordPress admin and choose WP-FFPC. Type unix:///tmp/memcached in the field Hosts in the tab named Backend Settings, this means it will look for a unix-socket with the path /tmp/memcached. You can also tick the box for Enable memcached binary mode for a bit extra performance gain.
Click Save Changes near the bottom.

The cache should now work. If you want you can also change how often the cache should be purged. As default the cache is set for 300 seconds (5 minutes), but feel free to experiment with the settings to see what works best for you. It also has an option to clear the cache manually if you have made a change that you want to show up right away.

We used the following settings for WP-FFPC for the tests we performed:

  • Select backend: PHP Memcached
  • Expiration time for posts: 14400
  • Expiration time for taxonomy: 14400
  • Expiration time for home: 14400
  • Cache invalidation method: modified post and posts index page
  • SHA1 hash key: Yes

Test results

The tests were performed with the Chrome web browser in Incognito Mode, with DevTools running and cache turned off. The page that was loaded was from Theme Test Unit and contained a gallery. We purged the cache between each test and also warmed up the cache by manually reloading the same page 5 times. Load time means the time it took for the server to generate and send the HTML document (at the top under Network DevTools). Click on the links to see a print-screen from the test.

PHP-version Load time OPcache Memcached
PHP 5.3 1610 ms No No
PHP 5.6 1290 ms No No
PHP 5.6 996 ms Yes No
PHP 7.0 529 ms No No
PHP 7.0 414 ms Yes No
PHP 7.1 536 ms No No
PHP 7.1 415 ms Yes No
PHP 7.1 15 ms Yes Yes


There are clear performance improvements made between PHP 5.3 and 5.6 and even more so when you reach 7.0 which is about twice as fast as 5.6. No major performance enhancements were made between 7.0 and 7.1.

The website loads faster if the OPcache extension is activated in cPanel. If we also activate Memcached with the WP-FFPC plugin the load times are almost 100 times faster when it is cached.

We should be aware of what cache plugin we choose. Some does not support other plugins like WooCommerce, WPML among others without some tweaks, or they might not work at all. WP-FFPC works well with a more or less static site that uses blog posts and pages, but less well with a web shop. For instance it works very well with the website you are on right now.

It is our recommendation that you first upgrade to at least PHP 7.0 if you haven’t done that yet and check that OPcache is active. If the web site is more or less static it is possible to try WP-FFPC to get a lightning fast web site!

Was this article helpful?

Related Articles