BACK TO TOP

What is WordPress Memcached and How to Use It

What is WordPress Memcached and How to Use It

When you have a website, its performance is one of those things that will keep you up at night. It can be perfectly fine, with all of the metrics and indicators in very respectable ranges of values, but you can still fret over it. Thanks to the many moving parts that influence how your website performs, there’s always something you might have overlooked, something you can tweak, something where the smallest of changes can produce tangible impact.

Caching certainly doesn’t belong to the small, easily overlooked techniques for boosting site performance. It’s a bona fides method for speeding up websites, and there are more than a few caching plugins for WordPress you can use. Within caching as a whole, however, Memcached tends to be overlooked. If you’ve been guilty of doing it but want to stop – you’re in the right place!

In this article, we’ll show you:

Qode Themes: Top Picks
Bridge New Banner
Bridge

Creative Multi-Purpose WordPress Theme

Stockholm WordPress Theme
Stockholm

A Genuinely Multi-Concept Theme

Startit WordPress Theme
Startit

Fresh Startup Business Theme

A Word or Two About Caching

A Word or Two About Caching

You probably know that people don’t like spending too much time waiting for a website to load. With every second of loading time, the likelihood that they’ll move away to another website grows. That’s why every second counts when it comes to keeping people interested in your website.

To lower the number of seconds people inevitably have to wait for a website to load, webmasters and admins employ something that’s called caching. Caching is nothing more than storing certain things in memory so that they can be quickly and easily retrieved, speeding up things such as loading a website.

There are many different sorts of caching. A content delivery network – CDN – will cache some of the contents from your page on their servers so that they load quickly when someone opens the page. Your web browser has its cache which stores HTML files and JavaScript to help websites load faster. There’s also server-side caching with software like NGINX that performs it.

And then there’s object caching – a type of caching people might overlook easily. While browsers and page caching tend to cache the heavier and unwieldier elements such as images, HTML, and other kinds of files, object caching is set on caching query results. That way, it can speed up the workings of your database, as they won’t have to generate results for every query – they’ll just retrieve them from the cache. WordPress has provided a kind of support for object caching for a long while.

What is Memcached?

Memcached

While WordPress might support object caching, you still need an engine to do it for you – a system that will commit the data to memory and retrieve it when needed. Memcached is that type of system. It’s open-source, which means you’re free to use it as you see fit. It works with distributed memory, which means it can help you pool resources. Its main job is to alleviate database load.

Using Memcached on your WordPress website gives you several distinct advantages:

  • All the caching occurs in RAM, so there’s very little loading of the CPU.
  • Because the data is cached in RAM, there’s no need to load it from the disk.
  • You can store all kinds of data with Memcached, although it’s meant for complex data.

The way Memcached works is fairly simple. A user sends a query. The server receives it, and it checks with Memcached to see if the needed data is stored in RAM. If it is, it’s sent directly to the user. If it’s not, Memcached requests it from the database, caches it, and sends it to the user. Neither you nor the user is aware of the process, of course, but you should notice after a while of using Memcached that your website is slightly faster.

Memcached has other advantages, too. It has a system that keeps the size of the cache under control by removing the least used queries, ensuring that the frequent queries stay cached. Memcached has its disadvantages, too – restarting the server wipes the cache, which means that you’ll need some time of reduced performance while you build it up again.

How to Use Memcached with Your WordPress Website

How to Use Memcached with Your WordPress Website

Memcached is third-party software – it doesn’t come with WordPress, and you’ll have to get it and install it so you can use it. Before you do that, however, you might decide to first test your website’s performance to see how well it’s performing without Memcached.

There’s a variety of tools for testing your WordPress website, and any that can test loading speeds can come in handy. After you’ve chosen one and established a sort of a baseline for your website’s performance, you can move on to the next step.

Memcached isn’t a plugin or an extension you can install on a WordPress website – it’s software that goes on the server. If you’re not comfortable with messing around the server or if you don’t have access, the easiest route to go is to contact your hosting provider and ask them whether they can install Memcached for you.

You might be surprised to learn that it’s already installed – many hosts have it, you just might not know it. From there, enabling it is a matter of simply logging into the control panel and finding the control for it. If you’re not sure what it is or how it’s called, as it might vary from one host to another, contact the support.

To make sure that Memcached is enabled, you should log into your SSH terminal via your hosting control panel, and use the Telnet command:

telnet [host] [port]

You’ll receive a message saying that you’re connected to localhost, at which point you can use the “stats” command to see some statistics about the connection.

If you want to and can take the DIY route to install Memcached, you should know a couple of things about it. Most of the Linux-based systems support Memcached. Many of them will provide their own packages for Memcached, and you should use them to install it as that’ll give you the best result with the least effort.

The commands you’ll use depend on the system. For Redhat or Fedora, you’ll use:

yum install memcached

For Ubuntu or Debian, you’ll use:

apt-get install memcached

If you’re using NGINX, you should know that it comes with a Memcached module.

The next step would be using caching plugins that support Memcached. There are quite a few of them, and many are out-of-date and seem abandoned. Still, a handful of big caching plugins work with Memcached, so they’re your best bet for setting it up. Plugins such as Litespeed Cache and W3 Total Cache support and provide options for object caching using Memcached.

Let’s Wrap It Up!

Object caching might be the underdog of the caching techniques to boost website performance. It’s effective, however, and relatively easy to set up and run. The bottom line, however, is that you can never have too many tools if all they do is help you speed up your website. You might as well use Memcached to give your WordPress website that extra boost and make it more competitive.

Post your comment

Comments0