April 25, 2023
Handle more traffic to your website: Enable Memcached in WordPress

As you attract more traffic to your WordPress website, the pages will gradually load slower — it’s only natural.

Your hosting server is handling more and more requests at the same time. Your entire website could crash as your visitors collectively download, comment, and submit files simultaneously.

This is where website owners may think, “It’s time to update my content delivery network (CDN).” That can help, but it comes at a price — literally. In contrast, caching is a way to increase your website speed without buying more bandwidth.

That’s where Memcached comes in: It uses server memory to speed up your website. That way, users can access it on demand — almost instantly — at reduced page load speeds.

Join us as we explore using Memcached in WordPress, how it works, its benefits, and how to install it on your server.

Here’s exactly what you’ll learn:

What is Memcached?

The Memcached homepage notes the support of several big brands, including Netflix.

Memcached is a high-performance, easy-to-use memory caching system that speeds up dynamic web applications.

Brad Fitzpatrick developed this open source solution for his website, LiveJournal. At this point, Memcached is used among the most popular websites, mobile apps, games, and ecommerce platforms.

Although it can be used as a standalone solution, Memcached typically works alongside:

  • PHP
  • Django (Python)
  • Ruby on Rails
  • MongoDB
  • MySQL
  • PostgreSQL

When you use WordPress with Memcached, visitors to your website will enjoy blazing-fast response times.

How? Memcached allows your host server to save frequently used data. Next time the data is needed, the server won’t have to request it from a database or search disk drives.

The Memcached object cache can store as little as an integer or as much as a full HTML page in your RAM.

What if you run out of space? Memcached will overwrite the data that has gone the longest without being used.

This all sounds good, but before you enable Memcached for WordPress, you should know a bit more about the program.

How does Memcached work?

A basic overview of how Memcached works.

Memcached stores frequently used data in your server’s RAM, which is easier to access than requesting info from your database. An application can access the data in microseconds rather than seconds since there’s no need to communicate with a database, search a disk drive, and transfer the info.

This reduces how long it takes for your website to respond to application planning interface (API) and database calls and render pages.

So how does it work? Here is a basic overview:

  1. An application (for example, a webpage) sends a data request to the Memcached server using a unique key to identify the data needed.
  2. Once it receives the request, Memcached accesses the RAM cache to check if the data requested is stored there already. If it is, Memcached delivers the data. Mission accomplished.
  3. Let’s say the data isn’t there. In this case, Memcached accesses your database in the website back end, retrieves the information, and stores it in memory. It also displays the information you requested.

Should the application request the same data in the future, the Memcached service will retrieve it from memory rather than the database.

However, this data isn’t permanently stored in the RAM. Memcached gives it an expiry date, automatically removing it from memory and creating space for future use.

Using WordPress with Memcached works this way to lessen the load on back end databases, which results in a faster, more efficient, scalable website for you and your audience.

The benefits of using Memcached on a WordPress site

The benefits of using Memcached on your WordPress site.

There are many reasons you’ll want to enable Memcached on your WordPress website. Let’s explore them below.

Memcached reduces response times to microseconds

In-memory data doesn’t have to make multiple round trips to the database and back to the application. That reduces the time needed to retrieve data, leading to blazing-fast speeds that improve app performance and user experience.

This alone is enough for many people to start their WordPress Memcached setup. Imagine response times measured in millionths of a second.

Memcached is flexible

You can use WordPress with Memcached to handle different data types, including simple data structures like integers and strings. It can also handle arrays and objects like documents, images, and videos.

Get fully managed WordPress hosting

Power your site with the industry's most optimized WordPress hosting

Memcached is user-friendly

Memcached was designed to be versatile and easy to use. Memcached is also open source and supported by many programming languages, including Java, PHP, C, C++, C#, Python, and Go. Multiple database languages also support it, including MongoDB and MySQL.

Memcached is scalable

Memcached uses multithreaded architecture, which lets it run several tasks within a single process at the same time. Because of this, you can scale it across servers to handle high traffic levels. When your audience grows, scale up by adding nodes to the existing node structure.

You can even use multiple core processors on a single node to increase your computing capacity, which leads to faster and more stable performance.

Memcached reduces database load

Using WordPress with Memcached reduces the number of database queries your host server needs to send to retrieve info from the database. This means the database is handling fewer requests at a time — so any requests that do need to be processed will be handled faster.

Your server is also less likely to be overwhelmed. This minimizes the risk of your website going offline due to server downtime.

Memcached has a massive, supportive community

Memcached has a massive community backing its open source project, so you can always find assistance when needed. Memcached depends on open standards and supports open data formats — this is possible because of a vibrant community backing.

Memcached is cost-efficient

By using WordPress with Memcached enabled, you avoid pricier hosting plans and hardware upgrades that your business doesn’t truly need yet. Using Memcached optimizes your website’s performance without the need to buy more processors and bandwidth.

Benchmark before your WordPress Memcached setup

When you enable Memcached for WordPress, the goal is to improve slow database queries to help overall website performance.

That raises the question: Exactly how well does your website currently perform? It’s a wise move to note your current standing before you begin the setup process.

There are plenty of tools you can use to monitor your website speed. Google’s PageSpeed Insights is an excellent place to start.

The homepage for Google PageSpeed Insights prompts you to enter a URL.

To test your website, go to the PageSpeed Insights homepage, enter your URL into the search box, and click Analyze to get your results.

Under the Diagnose performance issues tab, pay close attention to the metrics section. It gives you a detailed analysis of your website’s performance. Use these as your baseline before you activate Memcached.

The metrics section on Google PageSpeed Insights.

How to enable Memcached in WordPress

With your performance baseline in place, let’s see how much time you can shave off your page load speeds. First of all, your WordPress Memcached setup method will depend on several factors.

Some hosting providers offer caching support by default. If yours doesn’t, you can manually install Memcached on your server — if you have the right access to network protocols.

If you do have access to network protocols, you’ll need to access your server’s Secure Shell (SSH).

If that’s not an option for you either, contact your hosting provider so it can enable Memcached on your WordPress website.

Using SSH

Once you have accessed your server’s SSH command prompt, you can install Memcached using Linux commands. It’s best that you understand how your server’s particular Linux distribution works.

For instance, Debian and Ubuntu operating systems use slightly different commands than Fedora or Redhat. If you’re unsure about the install commands for your Linux distribution, you can check out its documentation.

In Ubuntu, use the command:

apt-get install memcached

In Redhat, use the command:

yum install memcached

When you’re done, go to the WordPress dashboard and download a caching plugin like W3 Total Cache to configure your WordPress Memcached module.

Contact your web hosting provider

Memcached is a popular software, and many hosting providers pre-install it on their servers.

Check with your host. If your host has pre-installed Memcached, you can enable it from your control panel. If the host doesn’t have it pre-installed, you could ask the support staff to set it up for you.

Final thoughts: Enable Memcached in WordPress to make the most of your hosting solution

Memcached remains a widely popular caching system because of its simplicity, speed, and scalability. It’s an efficient way to store and retrieve data from server memory — reducing the workload on backend databases and optimizing performance.

Memcached's flexibility and broad compatibility make it a valuable tool for all types of WordPress website owners — as long as they have enough RAM.

If you’re looking for hosting that supports high performing websites, consider Nexcess. Nexcess provides Redis for object caching with the Object Cache Pro plugin for integration into WordPress.

Additionally, you could have access to 32 GB of RAM with enterprise WordPress hosting from Nexcess, as well as 10,000 GB of bandwidth. Contact us today to discuss your hosting needs or enable Memcached on your WordPress website.

This blog was originally published in December 2017. It has since been updated for accuracy and comprehensiveness.

Maddy Osman
Maddy Osman

Maddy Osman is a WordPress expert, WordCamp US speaker, bestselling author, and the Founder and SEO Content Strategist at The Blogsmith. She has a B.A. in Marketing from the University of Iowa and is a WordCamp Denver organizer while also operating The Blogsmith, an SEO content agency for B2B tech companies that works with clients like HubSpot, Automattic, and Sprout Social. Learn more about The Blogsmith's process and get in touch to talk content strategy: www.TheBlogsmith.com

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.