{"id":58165,"date":"2020-11-12T12:22:00","date_gmt":"2020-11-12T18:22:00","guid":{"rendered":"https:\/\/blog.cpanel.com\/?p=58165"},"modified":"2020-11-12T12:22:00","modified_gmt":"2020-11-12T18:22:00","slug":"memcached-php-applications-for-faster-web-apps","status":"publish","type":"post","link":"https:\/\/devel.www.cpanel.net\/blog\/tips-and-tricks\/memcached-php-applications-for-faster-web-apps\/","title":{"rendered":"Memcached PHP Applications for Faster Web Apps"},"content":{"rendered":"\n

Caching is an indispensable feature of cost-effective application hosting and fast, low-latency user experiences. In-memory caching is one of the most widely used techniques, and Memcached\u2019s in-memory caching capabilities are used by thousands of developers, hosting providers, and web services giants<\/a> like Facebook\u00ae, Shopify\u00ae, and Slack\u00ae.<\/p>\n\n\n\n

In this article, we explore how Memcached works and how you can integrate it with PHP apps hosted on your cPanel & WHM server.<\/p>\n\n\n\n

Before we begin, a word of warning: the method outlined here should only be used on single-tenant dedicated servers, such as cPanel solo and virtual server hosting. It is not suitable for multi-tenant shared hosting environments without additional configuration to enable authentication or encryption.<\/p>\n\n\n\n

What is Memcached?<\/strong><\/h2>\n\n\n\n

Memcached<\/a> is an object caching system. It is primarily used to cache the results of database queries, helping dynamic websites like WordPress\u00ae and Drupal to serve pages faster. It can also significantly decrease resource use on a busy web server by reducing calls to the database.<\/p>\n\n\n\n

Like all caches, Memcached stores data generated by an expensive operation so that it can be used again without repeating the operation. For example, to build a web page, a PHP application often has to query a relational database like MySQL. Relational databases usually store data on a hard drive or SSD, both of which are slow compared to the server\u2019s RAM. Memcached puts often-used data in RAM, allowing it to be accessed a lot faster.<\/p>\n\n\n\n

Caching with Memcached works like this:<\/p>\n\n\n\n