Setting Up W3 Total Cache Plugin for WordPress
W3 Total Cache is a free alternative to WP Rocket with more flexible settings and support for multiple cache storage backends: Disk, Memcached, Redis, APC, CDN integration.
Choosing Page Cache Method
Disk: Enhanced—cache saved to disk, Nginx serves static files without PHP. Best choice for most hosting.
Disk: Basic—PHP checks for cache existence, less efficient.
Memcached / Redis—cache in memory. Faster than disk, but requires configured server and sufficient RAM.
For choice: if you have Redis or Memcached—use them. Otherwise—Disk Enhanced.
General Settings Configuration
Page Cache: ✓ Enable
Page Cache Method: Disk: Enhanced
Minify: ✓ Enable
Minify Mode: Manual (Auto breaks JS)
Minify Cache Method: Disk
Object Cache: ✓ Enable (if Redis/Memcached available)
Object Cache Method: Redis
Browser Cache: ✓ Enable
CDN: ✓ Enable (if using CDN)
Page Cache Setup
Page Cache → Page Cache Settings:
- Cache front page: ✓
- Cache feeds: ✓
- Cache SSL: ✓ (if site on HTTPS)
- Don't cache pages for logged in users: ✓
- Don't cache pages with GET parameters: ✓ (except utm_*)
Rejected User Agents (don't cache for crawlers):
.*bot.*
.*crawler.*
Rejected Cookies:
wordpress_logged_in
woocommerce_cart_hash
Redis Object Cache
// wp-config.php
define('W3TC_CONFIG_DATABASE', true);
In W3TC settings → Object Cache:
- Object Cache Method: Redis
- Redis hostname: 127.0.0.1
- Redis port: 6379
- Redis database: 1
Check: W3TC → Dashboard → verify Object Cache shows HIT.
Minification: Manual Mode
Minify → JS:
- Embed type: Non-blocking using "defer"
- Add each JS file manually with correct type
Minify → CSS:
- Embed type: Inline
- Combine files: ✓ (if HTTP/1.1, not HTTP/2)
Manual mode requires careful setup for each site, but won't break scripts automatically.
Browser Cache
Expires Headers for static files:
CSS, JS: 1 year
Images: 1 year
Fonts: 1 year
HTML: don't cache
W3TC adds Cache-Control and Expires headers via .htaccess (Apache) or requires manual Nginx setup.
Nginx Config for Disk Enhanced
# Cached pages
set $cache_uri $request_uri;
if ($request_method = POST) { set $cache_uri 'null cache'; }
if ($query_string != '') { set $cache_uri 'null cache'; }
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-.*.php|index.php|sitemap(_index)?.xml)") {
set $cache_uri 'null cache';
}
if ($http_cookie ~* "comment_author|wordpress_logged_in|wp-postpass|woocommerce") {
set $cache_uri 'null cache';
}
location / {
try_files /wp-content/w3tc/pgcache/$cache_uri/_index.html $uri $uri/ /index.php?$args;
}
Comparison with WP Rocket
W3 Total Cache is free and more flexible in settings, but requires more configuration time and careful minification setup. WP Rocket is simpler, works "out of the box" better, but costs money. For technical VPS users—W3TC is a reasonable choice.
Timeline
Installation and setup of W3 Total Cache with site-specific testing—4–6 hours.







