One of the most difficult plugins in terms of configuration is W3 Total Cache. At the same time, it is extremely useful for all WordPress sites, as it significantly increases the speed of the resource, reduces its loading time, and reduces the overall server load. After spending a little time studying this material, you will be able to figure out how to configure the W3 Total Cache caching plugin for WordPress.
Everything is as usual: through the admin panel, go to the "Plugins" tab and add a new one – through the search, we find W3 Total Cache and connect it. Before installing, be sure to remove any other caching plugins if you have used something similar before.
In the left menu of WordPress you will see the Performance tab – go there and click on General Settings. Here we will go through the main points that need to be configured:
Preview mode – enables or disables preview mode. When this option is active, the plugin works only for the user who configures it. It will be useful for those projects that have been online for some time and have accumulated some traffic.
The most important option, the inclusion of which activates the caching mode of web pages. This, in turn, reduces the server response time and increases the page loading speed.
Also here you can choose the method of caching site pages in the Page Cache Method item. We recommend installing Disk: Enhanced, since in this case the cache data will be stored on the server drive – as a rule, it is an SSD. Solid-state drives are extremely fast, so they are ideal for cache storage – reading this data will take fractions of seconds, so the benefits of the technology will be felt even more. You can also choose the method of storing the cache in RAM – it is even faster, but this is very wasteful since RAM is expensive and its volumes are limited. The method of caching using RAM is suitable only if your server has an excess supply of RAM.
Here we have 3 items that require setting up:
As for the HTML minifier, JS minifier and CSS minifier items, the default value will be recommended for all three.
An option that activates caching of compiled PHP code. We recommend installing Opcode: Zend Opcache, as this is the best option for VPS. There is also a Validate timestamps item here – we mark it with a checkbox so that the cache is updated correctly without having to restart the PHP module.
Enables caching of database requests. In practice, it reduces the time for generating website pages, and is an excellent alternative to an object cache when, for some reason, the latter cannot be used. You can use both technologies in parallel.
In the same tab, you can select Database Cache Method – Memcached will be recommended. We have a separate article about Memcached technology, we recommend reading it. In general terms, this technology allows caching data in RAM based on hash tables.
These are the page caching settings, which can be accessed by going to the path Performance > General Settings. Here we are primarily interested in the General tab with such items:
Here you can set the interval between cache updates, as well as specify the number of pages that will be cached at specified intervals. The higher the server capacity, the more pages should be specified, but you can only determine the optimal figure for your site by experience.
In this block, you can configure the mechanism for clearing the cache when creating and editing records, as well as when publishing comments. It is best to leave the default values.
In the advanced settings, the field of interest is the Garbage collection interval, since here we can set the interval for clearing the cache on disk. The higher the workload of your project, the lower the value should be set – this will allow you to get rid of the expired cache in a timely manner so that it does not overload the file subsystem.
In this block, we can configure the minification of the HTML code of the site pages. As practice shows, you will not get a serious performance gain from compressing HTML code, but activating this option can lead to problems with layout. Use at your own risk.
All other settings in this section can be left untouched.
Activate the W3 Total Cache minification, check the box next to Combine only, and do not touch anything else, there is no need.
Here you can specify advanced minification parameters. We need two parameters:
If you have a highly loaded project, the second parameter should be set with the lowest possible value. This will reduce the server load and increase the efficiency of the cache.
This page contains the browser cache settings, and for most cases you can leave the values that are set by default.
To enable Google Page Speed, you need to check the box next to "Enable Google Page Speed dashboard widget". Then you need to click on the "API key here" and paste it into the appropriate field. The key itself can be obtained on the official website. After saving the settings, go to the Debug section and disable all debugging options, since activating them only adds unnecessary code to your site. For the purpose of optimization, we disable it.