Bobcares

How to Integrate LiteSpeed Memcached with WordPress

by | Dec 26, 2024

Learn how to set up LiteSpeed Memcached. Our LiteSpeed Support team is here to help you with your questions and concerns.

How to Integrate LiteSpeed Memcached with WordPress

How to Integrate LiteSpeed Memcached with WordPressSlow-loading websites can discourage visitors and negatively impact our search engine rankings in the ever-evolving web development landscape.

One way to boost the speed of our WordPress site is to implement Memcached. This in-memory key-value store caches data to reduce the load on our database and API calls.

Today, we’ll set up LiteSpeed Memcached to optimize our WordPress performance.

What is Memcached?

Memcached is an open-source, high-performance, distributed memory caching system. It stores small chunks of data, such as objects and strings, retrieved from API calls, database queries, and page rendering processes. By caching frequently accessed data in memory, Memcached speeds up dynamic web applications by reducing the number of times our database or API needs to be queried.

Why Use LiteSpeed Memcached with WordPress?

Here are some of the benefits of integrating LiteSpeed Memcached with our WordPress site:

  • By caching data, our site responds faster to user requests.
  • Less frequent database queries mean lower server strain.
  • Efficient caching supports higher traffic volumes without degrading performance.
  • Faster websites lead to better user satisfaction and engagement.

How to Set Up LiteSpeed Memcached with WordPress

Before we begin, we need the following:

  • CloudPages deployed on the server. We can skip this step if we use a control panel like CyberPanel.
  • A WordPress site with an LSCache plugin installed.

If we haven’t already set up CloudPages, it offers an easy way to deploy a WordPress site with the LSCache plugin pre-installed. Once these prerequisites are met, we can install Memcached and its LiteSpeed PHP extension.

Method 1: Setting Up LiteSpeed Memcached Using the dir Backend

  1. First, we must update the server’s package list and upgrade existing packages to ensure compatibility and security.

    sudo apt update && sudo apt upgrade -y

  2. Then, install the Memcached daemon with this command:

    sudo apt-get install memcached

  3. After installation, check if Memcached is active and enabled:

    systemctl status memcached

    If the service is inactive or failed, activate and enable it with these commands:

    sudo systemctl start memcached
    sudo systemctl enable memcached

  4. We need the corresponding PHP extension to connect the WordPress site with the Memcached daemon. So, search for the Memcached extension compatible with our PHP version:

    sudo apt list lsphp* | grep memcache

  5. Now, replace 7X with our PHP version (e.g., 74 or 80) and install the extension:

    sudo apt install lsphp7X-memcached

  6. Then, log in to the WordPress admin panel and go to LiteSpeed Cache > Cache > Object Cache.
  7. Next, click on the Object Cache button. Then, keep the default Memcached port (11211) and click Save.
  8. Now, verify the configuration:
    • Memcached Extension: Enabled
    • Connection Test: Passed

    If both are verified, Memcached is successfully configured and active.

Method 2: Setting Up LiteSpeed Memcached via cPanel

If we are using cPanel, follow these steps to enable Memcached for our account:

  1. First, head to the LSMCD User Manager.
  2. Then, use the Change Password option to set a password for Memcached.
  3. Now, we have to enable the Memcached PHP extension. Go to cPanel > PHP Selector > Extensions and ensure the Memcached option is checked.

    Remember to enable only the Memcached extension, not Memcache.

  4. Go to the Access WordPress Admin Dashboard and head to LiteSpeed Cache > Cache > Object Cache.
  5. Now, verify the Object Cache is enabled. Select Memcached as the Method.
  6. Then, set Host to localhost and Port to 11211.
  7. Next, enter the cPanel username and password we set in the LSMCD User Manager and save the changes.

Once saved, verify that Memcached is active and functioning correctly.

Bonus Tips

  • Before making any changes, always back up the data to prevent potential loss.
  • Migrating containers or making substantial changes may require stopping services, which can lead to temporary downtime. To minimize impact, schedule these operations during low-traffic periods.
  • Different storage backends offer varying features. ZFS and Btrfs support advanced functionalities like snapshots, cloning, and quotas, while the Dir Backend is simpler and uses standard directories without advanced features. Choose a backend that aligns with the project requirements and technical expertise.
  • Ensure that the new storage location has the correct permissions and ownership settings. LXD and Memcached require appropriate access to manage container data and cache effectively.
  • After completing the setup, monitor the containers and Memcached performance to ensure everything operates as expected. Look out for any errors or performance issues.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

Implementing LiteSpeed Memcached can boost our WordPress site’s performance by reducing database load and speeding up data retrieval processes. Whether you’re using the dir backend or managing the setup through cPanel, following this guide will help us set up Memcached efficiently and effectively.

In brief, our Support Experts demonstrated how to set up LiteSpeed Memcached.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.