Many people will say that WordPress is not fast enough. This is mainly because there is no suitable cache plug-in installed. There are many kinds of WordPress cache plug-ins. Many people are a little confused and do not know which one to install.
Here we introduce the typical cache plug-ins in various situations, and then you can choose the corresponding cache plug-ins for your WordPress according to the characteristics of your server:
Object caching mechanism
The default caching mechanism of WordPress is called WordPress Object Cache. Its main function is to store the database query results or the results of complex operations into objects in such a way as Key Value. It also supports the division and avoidance of cached content conflicts by group.
The next time you perform the same operation, you can directly retrieve data from this object without repeating the operation to the database or other external websites. The different caching methods of WordPress are where to store the cached objects, or whether to cache the entire page.
File Cache
Before WordPress 2.5, WordPress can use file caching wp-config.php File Add define(ENABLE_CACHE,true); It can be enabled. After version 2.5, WordPress has canceled file caching and ENABLE_CACHE This global constant.
The file cache actually stores the objects cached by the WordPress object in the file, which has a problem. Every time you visit the page, you need to read many cached files. If your server's hard disk speed is not very fast, this will cause I/O congestion in your server. So WordPress 2.1 does not enable the file cache by default, 2.5 It was cancelled directly.
If you want to continue using the file cache, you can install this plug-in: File Based Extension to the WordPress Object Cache, and upload the downloaded files to wp-content Directory. Note that it is not plugins Directory.
Memory cache
Starting from version 2.5, WordPress recommends using memory cache. What is memory cache? It is to save the objects cached by WordPress objects to memory. The next time you access them, you can directly get the contents in memory.
With memory cache, there is no problem of massive I/O operations of file cache, and SQL queries are reduced a lot. The whole system is much faster. If it is done well, it can even be done 0SQL , such as Autumn Pro and Sweet themes.
However, opening memory cache requires the support of your server (general virtual hosts do not support it). Currently, memory cache generally uses Memcached or Redis.
WPJAM Basic has integrated Memcached wpjam-basic/template/ Under directory object-cache.php Files copied to wp-content Directory. Note that it is not wp-content/plugins/ Here is a detailed introduction to installing the Memcached cache plug-in.
Memory caching is the same as file caching, which divides the dynamic content of a page into many parts for caching according to its function, rather than treating the page as a whole cache. Therefore, accessing a page still requires reading multiple contents from memory, so someone has developed the Batchcache plug-in.
Batchcache caches the entire page in memory, so that when you access the WordPress page again, you can directly obtain the memory file from memory. This reduces the running of programs, reduces the CPU utilization again, and further speeds up the speed. However, it may also cause some function problems. Because the entire page is cached, it will have the same problem as the following static cache.
Static cache
If the server does not have ROOT permission, it cannot install the Memcached server services and PHP extensions, so you can use the HTML static cache plug-in.
This type of plug-in caches the entire WordPress page to a static HTML page and stores it on the server. The next time you visit the page, you don't need to run PHP code again. You can directly return the HTML file from the server, which greatly reduces the CPU utilization.
However, the use of HTML static cache plug-ins also has a disadvantage, such as article browsing, the latest articles, and these dynamic content will not be updated from time to time. Although we can solve this problem through Javascript and other methods, it is still too boring for ordinary users.
The most frequently used static cache plug-in is WordPress Super Cache, which is very flexible in setting, can distinguish between ordinary browsing users and registered users, and also supports mobile browsing. Here is my detailed introduction to the WP Super Cache plug-in.
The latest version of WP Super Cache also supports memory caching, so the system has installed Memcached+WP Super Cache at the same time. WordPress first stores the objects cached by default objects into memory, and generates static HTML files. Logged in users obtain various cached objects from memory, and unlisted users directly access static HTML, which is very efficient.
summary
So how do you cache your WordPress? Here's my experience:
Select VPS with excellent performance, such as Alibaba Cloud and Tencent Cloud. Using only the necessary plug-ins, WPJAM Basic integrates many functions. Install efficient WordPress themes, such as Autumn Pro or Sweet. If the server supports it, try to use memory cache. WPJAM Basic has integrated Memcached. Optimize WordPress.