Skip to main content
We are Brand SEO Beijing serving international business, your marketing partner, Contact us by mi@mgsh.com.cn

How to use Memcached memory cache to improve website speed?

when we doWebsite optimizationAt the time, website speed optimization is an inescapable topic. Improving the speed of the website is conducive to improving the efficiency of web spiders and crawlers and the reading experience of users. At the same time, it helps to increase the ranking and website weight.

What is Memcached?

Memcached is a high-performance distributed memory object caching system. Using Memcached in dynamic programs can not only improve the access speed, but also reduce the load of the database.
Memcached can store any type of data (strings, objects) generated from calling databases and APIs, or page rendering into memory, or read directly from memory.Its API supports most of the popular programming languages, Memcached's official website: http://memcached.org/
Danga Interactive originally developed Memcached to improve the speed of LiveJournal.com. At present, it has finally achieved as many as XNUMX million page visits per day to one million users, and these are managed by a Web server and database. A cluster of servers is completed.

PHP extension for Memcached

PHP has two Memcached extensions: "PHP Memcache extension" and "PHP Memcached extension", and this is where we get confused.
The PHP Memcache extension is implemented in PHP and supports both object-oriented and process-oriented interfaces. It was implemented in 2004. It is an old extension with few functions and few attributes that can be set.
The PHP Memcached extension is developed based on libmemcached. It uses the API provided by the libmemcached library to interact with the Memcached service. It only supports object-oriented interfaces. It was implemented in 2009. The Memcached extension function is more complete and supports more functions, such as supporting batch operations. It is generally recommended to use the Memcached extension.
Memcached can greatly improve the efficiency of website CMS
Some CMSs support Object Cache by default, so to implement Memcached in a website CMS is to use Memcached to write the Object Cache of the website CMS to the memory, and read it directly from the memory the next time you visit.Compared with reading data directly from the database, or saving the data from the Object Cache to a file, and then reading it from the hard disk, Memcached has a great speed advantage.
Memcached hit rate (usage rate)
Using the hit rate of cached objects after using Memcached, it can be seen that the hit rate is very high, close to 99%, which basically guarantees that all data is fetched from the memory, so using Memcached for caching is very effective.

How to enable Memcached caching

First of all, it needs to be clear that the Memcached server and its PHP extension must be installed at the same time.
If the Memcached server is installed and the extension is not installed, then PHP cannot control Memcached.Also if the PHP Memcached extension is installed, but the Memcached server is not installed, this will not work.
1. First, the server needs to install the Memcached server, and then PHP needs to install the Memcached extension. Note again that PHP has two extensions: PHP Memcache extension and PHP Memcached extension. The difference between the two is only a letter D, you can pass phpinfo() this PHP function to see which extension is installed, be sure to use the PHP Memcached extension.
2. Use the plug-in to integrate the function of Memcached, copy the object-cache.php file in the wpjam-basic/template/ directory to the wp-content directory, note that it is not wp-content/plugins/, we have to put the data that needs to be cached under the root directory.
3. The website CMS will automatically check whether there is an object-cache.php file in the wp-content directory, and if so, directly call it as the website CMS object caching mechanism.
4. After the installation is successful, the plugin will automatically see the Memcached information under "System Information" under the WordPress > WPJAM menu:
Plugins - System Information - Server
Wordpress CMS plugin developer: I love the planet of poached fish jam

Extended reading:
How to access static web pages through Alibaba OSSbucket in Quick Site?
How to realize the dynamic and static separation of pictures, JSS, etc. through Ali OSS?
How does the website achieve dynamic and static acceleration?
How to Get Started Optimizing Your Website in Five Minutes Using the Beginner's Guide to SEO?

Back to Top