Choosing the best settings for W3 Total Cache
Some people use the “W3 Total Cache” plugin to speed up their WordPress website. It’s possible to get good results with W3 Total Cache, but our experience has shown that it’s easy to accidentally configure it in a way that inadvertently reduces your website’s performance.
If you use W3 Total Cache, use these settings in the “Performance” > “General Settings” menu:
- Enable the “Page Cache” option, using “Disk: Enhanced” as the method
- Disable the “Database Cache” option
- Disable the “Object Cache” option
(The other settings aren’t as important, and you can leave them alone or choose whatever you want.)
After choosing these settings, you should check the HTML source code of a page from your website and verify that it does not include anything about “Database Caching” or “Object Caching” — that is, it should not include anything like this at the bottom:
Database Caching 12/34 queries in 0.567 seconds using disk Object Caching 123/456 objects using disk
Disabling from the command line
$ wp w3-total-cache option get dbcache.enabled --type=boolean true $ wp w3-total-cache option get objectcache.enabled --type=boolean true $ wp w3-total-cache option set dbcache.enabled false --type=boolean Success: Option updated successfully. $ wp w3-total-cache option set objectcache.enabled false --type=boolean Success: Option updated successfully. $ wp w3-total-cache option get dbcache.enabled --type=boolean false $ wp w3-total-cache option get objectcache.enabled --type=boolean false
Why not use database and object caching?
It may seem counter-intuitive to avoid some of the “caching” options the plugin offers. There’s a good reason for it, though.
“Caching” means “storing data that was slow to generate in a place that’s quicker to access”. Caching is generally a great way to increase WordPress speed: the W3 Total Cache “Page Cache” stores finished pages to avoid running any PHP scripts for most requests, for example.
However, our servers use gigabytes of MySQL database cache memory, and even non-cached reads come from extremely fast solid-state drives on the same server. This means that when WordPress queries your database, it’s lightning-fast.
If you enable database or object caching to disk, though, it can write hundreds (even thousands) of files per minute on a busy site. Writing these cache files to a disk is much slower than reads, defeating the advantage you get from fast MySQL servers.
It’s okay to use “page caching” to the disk because it’s normally just a handful of files per minute, and the benefit it gives (avoiding PHP scripts completely) is very large. But database and object caching cause vastly more disk writes compared to the potential benefit they provide.
Other advice for W3 Total Cache users
If you’re running WordPress, we recommend using the WP Super Cache plugin instead of W3 Total Cache. WP Super Cache offers the same performance increase from page caching, but it’s simpler to set up correctly.
Copyright © 2000-2023 Tiger Technologies LLC