How do you use Memcached on your cPanel website?

Procédure

What is Memcached?

Memcached is a service for storing objects in memory. This service enables you to store and then retrieve "objects" such as binary data or MySQL query results very quickly. Its main advantage (but also its main drawback) is that all the data is stored in RAM memory: access is therefore very fast, but it is volatile (all the data will be deleted as soon as the service is restarted).

What are the benefits for my site?

Although the Fastest Cache module supplied and pre-activated on our cPanel web hosting packages already gives you a high-performance page caching system, you may also need to optimise dynamic pages such as search pages, shopping basket pages, news feeds, an instant messaging system, a comments list or a member area.

Unfortunately, these highly dynamic pages cannot be cached in their entirety because their content changes very frequently. If the data is retrieved instantaneously from the database (PostgreSQL or MySQL), you run the risk of both saturating your database server and experiencing mediocre performance.

To remedy this, you can, for example, store the names of the most popular products and their prices in an object cache system. This way, when the shopping basket page loads, you won't have to execute an SQL query to retrieve the most popular products. Your site will be faster and your MySQL or PostgreSQL database will be under less strain.

How do I use Memcached on PHP?

There are two different PHP extensions that can be used to enable a PHP script to communicate with a Memcached server: memcache and memcached. It is important to check with the author of your script to find out which of the two is used by your site. To activate one of them :

1. Connect to your cPanel interface and click on"Select a PHP version" in the"Software" section.

How do you use Memcached on your cPanel website?

2. Tick"memcache" or"memcached" as required.

How do you use Memcached on your cPanel website?

That's it. You can now connect to the memcached servers from your PHP scripts. An instance of memcached is available by default on your cPanel account. Here are the connection details:

  • Host: localhost
  • Port: 11211 (tcp)

How can I use Memcached as an object cache on WordPress?

WordPress already has an object cache ecosystem that allows plugins and themes to ask WordPress to store the result of a complex MySQL query in memory. This works with the WP_Object_Cache class. By using memcached as a storage space for WP_Object_Cache, WordPress can take advantage of memcached's performance.

The"Memcached Object Cache" WordPress plugin allows you to do this with the memcache PHP extension, which should be activated beforehand (see previous paragraph). To install it, download the plugin's object-cache.php file and place it in your website's wp-content folder ( using FTP or the cPanel file manager):

How do you use Memcached on your cPanel website?

Next, you will need to fill in a cache key so that your website knows which data on memcached is its own. This is done by adding the line"WP_CACHE_KEY_SALT" to wp-config.php:

How do you use Memcached on your cPanel website?

And that's it.

How do I configure MemCached on WordPress with W3 Total Cache?

1. Connect to your Wordpress interface and click on"Extension/Add" to install W3 Total Cache.

How do you use Memcached on your cPanel website?

2. Search for the"W3 Total Cache" plugin and click on"Install maintenance".

How do you use Memcached on your cPanel website?

3. Click on"Activate".

How do you use Memcached on your cPanel website?

4. Look for the plugin in the list of plugins and click on"Settings" below it.

How do you use Memcached on your cPanel website?

5. Go to the"Database caching" section, tick the"Enable" box and enter"memcached" in the"Database cache method" section. Finally, click on"Save setting and purge cache" to save your request.

How do you use Memcached on your cPanel website?

You can perform the same operation for the"Object cache" section. The Object cache allows you to cache only the results of database objects.

How do I configure MemCached on Prestashop?

1. Connect to your Prestashop dashboard, click on "Advanced settings" and then on"Performance".

How do you use Memcached on your cPanel website?

2. Go to"Cache", click on "Yes" then choose"memcache" or"Memcached" depending on the extension you activated when selecting your PHP version. Finally, click on"Save" to save the request.

How do you use Memcached on your cPanel website?

Conclusion

You are now able to configure Memcached on your cPanel hosting package for WordPress or Prestashop. However, it should be noted that all data on Memcached is accessible to all users on the same cPanel server as yours. For this reason, it is imperative that you never store sensitive information on Memcached.

Don't hesitate to share your comments and questions.

Rate this article :

5/5 | 1 opinion

This article was useful to you ?

Article utileYes

Article non utileNo

Vous souhaitez nous laisser un commentaire concernant cet article ?

Si cela concerne une erreur dans la documentation ou un manque d'informations, n'hésitez pas à nous en faire part depuis le formulaire.

Pour toute question non liée à cette documentation ou problème technique sur l'un de vos services, contactez le support commercial ou le support technique

MerciMerci ! N'hésitez pas à poser des questions sur nos documentations si vous souhaitez plus d'informations et nous aider à les améliorer.


Vous avez noté 0 étoile(s)

Similar articles

1mn reading

How do I configure Cloudflare on a website hosted on cPanel?

4mn reading

Using Redis as a persistent object cache for WordPress on cPanel

4mn reading

Speed up your site with Fastest Cache - Cache Varnish

3mn reading

How can I use IpXchange to customise the IP of your domain?


Ask the LWS team and its community a question