Blog

Provide customers with quality service is always our mission, customer recognition is always our pursuit!

Pure Dry Goods! Caching plugin W3 Total Cache setup tutorial (Pro), illustrated, bypassing dynamic caching

W3 Total Cache Pro(referred to as W3TC) is an old cache plug-in, free version has more than one million installations, many positive reviews. W3TC is a comprehensive and powerful, can be very fine control of the cache content, acceleration is very good, can do a lot of other cache plug-ins can not do things.

W3TCDynamic content caching can be bypassedW3 Total Cache Pro is a powerful caching plugin that provides object caching, database caching, fragment caching, shrinking HTML/CSS/JS/etc. to greatly reduce the burden on the server and shorten the page loading speed. It is a really useful caching plugin, this site uses W3 Total Cache Pro (Click to download) Acceleration.

As soon as this site started usingWp RocketAccelerate, but visitors still show unlogged in status after logging in (avatars and other content are not displayed). Then I tried Fastest Cache, Super Cache and other plugins and still could not log in properly. Finally, I usedW3 Total Cache ProPerfect solution to the problem.

Because there are too many setting options, many people do not understand the settings lead to the effect can not be played, so it is not as famous as Wp Rocket, Fastest Cache. in fact, if used properly it is better than Wp Rocket! Write this W3 Total Cache setup tutorial is designed to help you understand, make the settings suitable for their own sites.

W3 Total Cache is not popular with other caching plug-ins in addition to cumbersome settings there is another reason is that it does not have to generate the key CSS and delayed loading of JS functions, resulting in poor results by a long shot. It is recommended to usePerfmatters Asset Cleanup PluginUsed, the 2 together definitely function and work better than the Wp Rocket.

Note: For Nginx systems, if the content in the nginx.conf file changes after changing the W3 Total Cache settings, you need to restart Nginx for it to take effect.

 

 

W3 Total Cache Setup Tutorial

Different sites are different, the following settings are for reference only.Settings that you don't understand are recommended to be left at defaultIf you are using the free version, some features will be disabled. The screenshot of the setup tutorial below is the W3TC Pro interface, if you use the free version some features will be shown disabled. If you have any questions, please feel free to leave them in the comments below. Let's start with some basic concepts:

Page Cache - When a visitor accesses a page, the server needs to query the database and run a script to generate the input page. Turning on page caching will store a copy of the completed page so that subsequent visitors can access the page directly without querying the database and running scripts, thus greatly reducing page loading time and server pressure.

Opcode Cache - Caching the results of compiled PHP code makes subsequent requests for the same PHP code faster.

Fragment Cache - A page may be some of the content is dynamic , if the use of page caching default dynamic content will become static can not be updated in a timely manner.Fragment Cache role is through the use of PHP templates inside the specified code wrapped in dynamic content plate , so that the page cache bypasses the cache this part of the dynamic content only cache other content , especially suitable for e-commerce or membership site .

Fragment Cache can only be used in PHP templates, the use of the scope and conditions are more limited, click theSee how the fragment cache is specifically usedThe

Note: Enabling fragment caching may result in editing functions.php and other files can not be saved, first temporarily disabled, edit and then open or insert the code with the plug-in instead (not using functions.php).

Object Cache - Caching the results of completed database queries. While page caching can greatly help reduce site response times by caching static pages, there are still many uncached object requests. Object caching will further improve performance by caching these objects.

Object caching allows for more efficient retrieval of data from the database. Its purpose is similar to the role of database caching. However, object caching is more efficient compared to database caching because it allows fewer requests to be processed.

Object caching is a way that WordPress core, themes and plugins can store some frequently accessed and rarely changed data in an object store. This eliminates the need to retrieve and process these objects on every request. Ultimately, object caching will reduce the total number of database queries required for each page, and since the CPU doesn't have to rebuild these chunks of data, your response time will be reduced.

Database Cache - Caching MySQL database query results helps to free up MySQL server resources tied up by repetitive queries that return the same data every time, so that it has more capacity to work with truly dynamic data.

Although the object cache will store executed PHP, it may not contain information retrieved from the database and will not cache most calls to the database. If there are many database queries being executed after the object cache is enabled, database caching should be enabled, and vice versa is not recommended.

Database caching is not compatible and many hosting merchants recommend disabling it. Try disabling it if you have problems.

In summary: object caching is a supplement to html page caching to catch leaks (some dynamic requests that are not cached), while database caching is a supplement to object caching to catch leaks (some object requests that are not cached).

Under normal circumstances, both object caching and database caching should be enabled, but server memory and database conditions vary, and sometimes querying content directly from the database is faster than querying from memory and disk. So you need to use W3TC Setup Guide to test the actual effect of different caches and then set them accordingly.

Browser Cache - This puts a copy of the page into the user's browser cache. When that user revisits the same page using the same browser, it will be loaded from the cache stored on their computer instead of querying the web server.

Disk: Basic - This method will call a PHP script to serve the cached page.

Dick: Enhanced - This method will modify the .htaccess file to direct Apache to a static cached version of the page, and is therefore faster than Disk and is recommended. If the site slows down, use Disk: Basic instead.

Dick (disk) cache- Store cached files on disk.

Memcached Cache - Storing cached files in memory is faster than Dick (disk) caching in the vast majority of cases. ViewDick Cache vs Memcached Cache Speed ComparisonThe

Tips: Shared hosting (server) disk read and write speeds are generally limited and not very fast. So if you enable database caching or object caching for shared hosting, the method try not to choose disk, it is recommended to choose memory (Memcached/Redis).

 

Setup Tutorial:
First use the Setup Guide to test the settings suitable for your website, click "Setup Guide" to enter the quick setup guide. Note: The actual access speed of the front desk must prevail, this test may not be accurate. After setting up the test, the speed is slow to change the settings or disable the database cache and object cache function.

Pasted 78

Tap "Next"↓.

Pasted 33

Tap Test Page Cache↓

Pasted 79

Select the one with the shortest time. Tap "Next" for the next test. AllAfter setting up, if the website access speed becomes slow, try to change the page caching option. We had a site that was very slow with Disk: Enhanced, so we changed it to Disk: Basic and the speed went back to normal.

Pasted 80

Pasted 33

 

It is not recommended to enable both database caching and object caching at the same time, there may be bugs and the speed will be slower, just enable one. If the site slows down after enabling one of them, disable both caching functions.

If you decide to enable database caching, regardless of the results of the test, select the memory cache (Memcached or Redis) is more effective and stable. Click "Next" when you have made your selection.

If you are using shared hosting such as SiteGround, CPU and memory limitations may be severe, and the database caching method may be slowed down if you choose memory (Memcached/Redis), so the hosting Chamber of Commerce recommends that you choose "Disk" for the caching method.

Using the disk method of caching databases on shared hosting may slow down the site because it is faster to get data from the database than to get cached data from the disk. To summarize: it is recommended to disable database caching if you are using shared hosting, the speed may be faster.

Pasted 82

 

The following object caching test results show that None time is the shortest, select "None", click "Next". If you disable the database cache (the above test results choose None), object caching test results may be completely different, if you enable object caching is generally recommended to choose Memcached (Pagoda Panel needs to be installed in PHP Memcached extension).

 

Pasted 81

 

Browser cache directly select "Enabled", click "Next".

Pasted 83

W3TC's delayed loading compatibility is not good, and many people in the forum post that images are displayed abnormally after enabling it. It is recommended to usePerfmatters's image delayed loading feature instead (works best). If you already use delayed loading in other plugins, don't enable it here, otherwise enable it. Tap "Next", then tap "DASHBOARD" to go back to the dashboard.

Pasted 84

This is the end of the setup wizard. If you are not a shared host, it is best to restart Nginx for the settings to take effect. Let's start setting up General Settings.

 

 

General Settings settings

Page Cache is already enabled and selected in the Setup Wizard, so there is no need to set it up again, just skip it.

Pasted 123

 

Minify set up according to the chart, Minify mode must be selected Manual, if you choose Auto website display a high probability of problems. Minify Cache Method Pick Dick is safer, choose other easy to error. The other 3 items according to the chart, here only use W3TC compression, it's delayed JS / CSS function compatibility is not good effect is generally not recommended to choose.

Pasted 124

 

Opcode Cache is set up as shown ↓.

Pasted 125

 

Database Cache, Object Cache and Browser Cache have already been set up in the Setup Wizard above, so just skip them here and ignore them. If you don't want to enable database caching in the future, remember to come back here to enable database caching instead, and select Memcached for the Method.

Pasted 126

Pasted 127

Pasted 128

 

If you use CDN, you need to change the resource url inside the html to CDN url, so that you can load resources from CDN.Wp Rocket, Perfmatters and other plugins have CDN rewrite url function. Only need to enable this function in a plug-in on the line, do not enable it in more than one plug-in, there will be a conflict.

We use W3TC's CDN function to rewrite the URL found that Perfmatters delete useless CSS generated used.css can not be loaded, suggesting that the URL error. After using W3TC's CDN function to rewrite the URL, I found that Perfmatters' used.css generated by deleting useless CSS could not be loaded, and it indicated that the URL was wrong. Try not to use W3TC's CDN function if you have a choice.

If only W3TC this plug-in CDN function, then use it. The use of domestic Tencent Cloud, Seven Bulls Cloud and other CDN selection "Generic Mirror" ↓.

Pasted 129

 

Reverse proxy is a reverse proxy that sits between a web server and WordPress and can be used to perform a variety of logic-based operations on incoming requests. Don't touch it if you don't know what it means, just skip it.

Pasted 130

 

Message Bus the vast majority of people can not use ↓, if you do not understand what it means directly skip.

Pasted 131

 

User Experience settings are left at default and skipped directly. Here you can enable delayed loading of images and Google Maps as well as disable emoji. These features are available in thePerfmatters pluginIt's all in there and it works better.

Pasted 132

 

Statistics analyzes website and server caches and is used to track the size, timing, and hit/miss rates of each, providing the information needed for optimal performance. When enabled, in the Statistics section of the W3TC SettingsPasted 146tab to view the information.

Enabling it adds a bit of server load, enable it as needed.

Pasted 133

 

Fragment Cache enabled ↓, select Memcached.

Pasted 134

 

Miscellaneous all options remain default, just some auxiliary role, if you do not understand directly skip better.

Pasted 135

 

Debug debug mode ↓ disables specific caching layers and optimization settings. For example, if you notice visual glitches on your site, you can enable debug mode for the "Minify" option, which inserts HTML comments into your page's source code to help you troubleshoot.

If you find a problem with any cache, check the appropriate cache point in the settings below to save it. The debug mode feature puts an extra load on the server resources, so it is recommended to use it only during low-traffic periods, and remember to disable debug mode after you have finished troubleshooting.

Pasted 136

 

Import / Export Settings is the export-import settings, understood at a glance.

Pasted 137

The General Settings settings end here, and the following are the detailed settings for each function.

 

 

Page Cache Settings

Set up page caching here, just follow the picture.

Pasted 138

 

The Aliases feature allows caching of the same WordPres content available on different domains (e.g. domain.com and www.domain.com). We do not recommend enabling this feature, and if there are different domains it is best to 301-redirect to the same domain to avoid the risk of getting a "bad" response from Google and other search engines.Duplicate Content Penalty.

Pasted 139

 

Cache Preload is the cache preload function, set it according to the picture, enter the full URL of your website sitemap (.xml ending) in the red box. Otherwise, keep the default, if the preload interval is too short, it will lead to high load on the server.

Pasted 140

 

Purge Policy: Page Cache is a setting for when the website page cache should be cleared automatically. If you don't know what to choose, set it up as shown below and use it for the vast majority of websites. The cache will be automatically cleared when a page/article/listing page is modified or when there are new comments on an article.

Pasted 141

The unchecked items in the picture below are useless, as is the Blog feed, which is not recommended to be checked.

Pasted 142

 

REST API ↓ set whether to cache REST API, REST API allows you to query JSON format data, we recommend that you select "Don't cache'". Our previous choice of "Cache" led to the failure of the WeChat public number custom reply function, and the choice of "Disable REST API" led to the abnormal function of the hidden protected content plugin.

Pasted 143

 

Advanced settings, it is recommended to keep the defaults except for those mentioned below.

Late initialization and Late caching are only suitable for some plug-ins in some cases, in most cases you don't need to enable them. If you select "Disk: Enhanced" for Cache Page Method: in General Settings, Late initialization and Late caching are not available. Change it to "Disk: Basic".

Late initialization:I.e., delayed initialization, is a method of initializing an object in programming. An object is created in memory only when another object references it. Delayed initialization relies on the fragment caching feature, so don't enable it if you're not using fragment caching.

Late caching:I.e. delayed caching is a method of delaying the caching of pages. It allows to load part of the WordPress content before the cache is processed by W3 Total Cache. Delayed caching can be used in certain situations, such as for geolocation purposes. In most cases, it does not need to be enabled.

Compatibility mode. If you select Dick: Enhanced, a new Compatibility mode option will be added under Late caching. The official recommendation is to enable this feature only when encountering problems related to Apache rules, after enabling it, the performance will be reduced by about 20%.

Pasted 229

Pasted 144

Rejected cookies↓: Enter the cookies for the content that needs to be bypassed for caching, one line at a time.

Never cache the following pages↓: Put the URL of the page that does not need to be cached into, one line at a time.

Pasted 145

 

 

Minify Settings

Setting compression of HTML, CSS, JS details, here if the settings are not right website is prone to display errors, set up according to the chart. If the site shows errors, note that the disable option to troubleshoot.

Pasted 26

Pasted 27

Pasted 28

Pasted 29

 

 

Database Cache, Object Cache, Fragment Cache

The settings inside these 3 tabs can be left at default if you don't know what they mean.

Database Cache (Database Cache) and Object Cache (Object Cache) play a big role, in some cases may lead to website problems. For example, the database cache may lead to high CPU usage, if the problem disable these two functions one by one, clear W3TC cache to troubleshoot the problem.

After enabling Object Cache, if the website background plug-in settings, article editing and other functions appear abnormal, switch to Database Cache or close the function to try.

 

 

Browser Cache

Set ↓ according to the figure. If your site has dynamic content do not want to be cached, the following figure three red content do not check, otherwise check.

Pasted 148

Pasted 149

 

CSS & JS settings as per the below image.

Pasted 150

 

HTML & XML settings in accordance with the following chart, if your site has dynamic content does not want to be cached, the following three red content do not check, otherwise check.

Note: The Set cache control header below will sometimes be enabled automatically after modifying other WT3C settings or upgrading the plugin, resulting in some dynamic content being cached. If you want to bypass the dynamic content cache, check this item every time you upgrade W3TC plugin or modify the configuration, and keep it disabled.

Pasted 151

 

Media & Other Files set ↓ as below, other options remain default.

Pasted 153

 

Security Headers don't help much with speed, but they do improve site security.

Pasted 154

Pasted 155

Pasted 156

 

 

Cache Groups (separate cache for mobile)

The role of Cache Groups is to set up a separate cache for cell phones, according to the picture to enable tablets (desktop) and phones (cell phone) user groups, select tablets and phones to use the corresponding theme, if you just use a theme (responsive), just select the same. Other settings remain default.

Many optimization features rely on separate caching for cell phones, for example, Perfmatters plugin control code is only enabled on cell phones and requires the site to enable separate caching for cell phones before it can take effect.

tablets ↓

Pasted 51

phones(cell phones)↓

Pasted 52

For more details check out:https://wordpress.org/support/topic/set-up-the-caching-separately-for-mobile-and-desktop/The

 

 

CDN Settings

If not using a CDN don't set it up here. If you have a plugin like Perfmatters installed, it's better to use the CDN feature of Perfmatters.

Enter the accelerated domain name and save.

Pasted 39

You can click "Test Mirror" to test it, and "Test passed" means success.

Pasted 40

Check if the frontend display is normal, check the source code and find that the resource URL has been changed to a cdn accelerated domain.

Pasted 41

Other settings remain default.

 

 

User Experience

Here you can set the delayed loading content of images and Google Maps, if you don't enable the corresponding function, you don't need to set it. If you have enabled delayed loading, just set it according to the picture.

Pasted 158

 

 

Extension

Here are some extensions to enable Fragment Cache by default for Pro version. if using Yoast plugin, install Yoast SEO extension. If you are using Cloudflare CDN, install CloudFlare extension.

The Image Service extension can generate WebP photos, but we have tested it on several sites and found that the conversion is unsuccessful, it keeps prompting that the conversion is in progress, so it is not recommended to enable it. To optimize photos, please checkThe Ultimate WordPress Image Compression and Optimization Tutorial.The

 

 

caveat

 

Exclude specific pages from being cached

Backend login address, personal center, shopping cart and other pages should not be cached and need to be excluded. In Page Cache > Advanced settings, Never cache the following pages: fill in the page URLs that need to be excluded from being cached.

Pasted 115

 

 

Bypassing Dynamic Content Caching

If there are problems such as not logged in status after login, user's avatar and some content visible after login are not displayed, sidebar is not displayed, etc., follow the method below to set it up. Methods fromW3TC Support ForumEnter the Browser cache settings page. Go to the Browser cache settings page.

Pasted 30

Top General↓Below 3 items are unchecked.

Pasted 31

HTML & XML ↓ The following 3 items should be unchecked.

Note: The Set cache control header below will sometimes be enabled automatically after modifying other WT3C settings or upgrading the plugin, resulting in some dynamic content being cached. If you want to bypass the dynamic content cache, check this item every time you upgrade W3TC plugin or modify the configuration, and keep it disabled.

Pasted 74

If you still can't bypass the PHP cache after setting it up as required, enter the page cachePasted 102Settings, check if the following 2 items can be checked (enabled). If they can be checked, try enabling them both.

Pasted 103

 

 

W3TC Frequently Asked Questions

1- Modify after installing W3TCfunctions.phpetc. If you are prompted with the following question, just temporarily disable the Fragment Cache feature. The best way to add code is to use theCode SnippetsPlugins that are safe, stable and efficient.

Pasted 112

W3TC > General Settings, turn off Fragment Cache as shown below.

Pasted 113

 

2- At first I was able to bypass the PHP cache and log in normally to show some content, then after a while the login was disabled by the cache. I found that if you change the settings for database caching, object caching, etc., especially the caching method, the red box under the Broswer Cache setting is automatically checked. Go check it and if it is checked, uncheck it to save the setting and clear the cache.

Pasted 114

If it still does not work, the Page Cache settings inside the Late initialization, Late caching were opened to try.

 

3- Frontend prompt mysqli_num_fields() expects parameter 1 to be mysqli_result, bool given in /www/wwwroot/xxx.com/wp-includes/class-wpdb.php on line 3574

W3TC Database Cache (Database Cache) to cause this problem, turn off the database cache to use the object cache (Object Cache) can be.

 

Other more settings to seeDetailed W3 Total Cache setup tutorialAlthough this tutorial is a bit old, it is written in great detail. Some options may be out of date to see the content of the settings, for example, tutorial page cache settings inside an option is "Cache front page" (recommended to check), is in the new version of this option becomes "Don't cache front page "(not recommended to check), the meaning is completely opposite.

For more settings and questions check outofficial document,Official Support ForumThe

 

4- After using W3TC the speed becomes much slower. The situation may vary a lot from service to service, maybe some servers are not configured properly, have many limitations or bugs (e.g. MariaDB 10.7.3 database in Pagoda Panel is unstable).). So after using this plugin it may be slow due to some errors.

If the speed becomes slower, try one by one: 1- change the caching mode of page cache to Disk: Basic; 2- change the caching mode of database cache and object cache one by one, or close them; remember to clean up the cache after modification to check the latest effect.

Scroll to Top