Issue
The Time to First Byte (TTFB) on the WooCommerce store homepage has surged from a normal 0.2 s to 2.3 s, and WP Rocket’s page caching has completely failed. No cache files are being generated at the nginx level, and every request is hitting PHP directly.
Environment
- WordPress 6.9.1 multisite (subdirectory mode)
- WooCommerce 10.3.7
- WP Rocket 3.x + Object Cache Pro (Redis)
- PHP 8.3, nginx
Troubleshooting Process: Isolating Issues Layer by Layer
Layer 1: Redis Crash
Redis maxmemory was set to 6 GB, but actual usage exceeded this limit, causing Object Cache Pro to frequently fall back to database queries.
Fix: Increased maxmemory to 8 GB and configured Object Cache Pro with maxttl=86400 to prevent unbounded cache growth.
Layer 2: mu-plugin Injecting no-cache Headers
A mu-plugin—intended to block analytics scripts—was injecting the Cache-Control: no-cache HTTP response header via the wp_head hook. WP Rocket detects this header and skips writing to the page cache.
Fix: Removed the mu-plugin (its functionality is now covered by alternative means).
Layer 3: Mandatory Cookie from Multi-Currency Plugin
WP Rocket’s configuration included a mandatory cookie set by the YITH Multi-Currency plugin. The logic was: only requests carrying that cookie would be cached. However, first-time visitors lack this cookie, so no cache file is ever generated—creating a catch-22.
Fix: Cleared the mandatory_cookies setting in WP Rocket. Currency selection was moved to frontend JavaScript, eliminating server-side cookie-based routing.
Layer 4: WooCommerce API Manager Disabling Homepage Caching
After resolving the first three layers, caching worked correctly for inner pages—but the homepage remained uncached.
Tracing revealed that the WooCommerce API Manager plugin contains logic in wc-am-smart-cache.php: when the constant WC_AM_DISABLE_HOMEPAGE_CACHE is true (its default value) and the current page is the homepage, it sets DONOTCACHEPAGE = true. WP Rocket’s can_process_buffer() then detects this constant and aborts caching.
Fix: Added the following line to wp-config.php:
define('WC_AM_DISABLE_HOMEPAGE_CACHE', false);
Result
TTFB dropped from 2.3 s to 0.18 s (cache hit). The full flow—including WooCommerce’s geolocation_ajax 307 redirect—is now ~0.9 s.
Lessons Learned
- WP Rocket cache failures require layered diagnosis: Check response headers → mu-plugins/plugins interfering → WP Rocket’s own configuration → third-party plugins setting
DONOTCACHEPAGE mandatory_cookiesis a trap: Though designed to enable cookie-based cache variation, if the first visitor lacks the cookie, no initial cache file is ever created.- WooCommerce API Manager disables homepage caching by default: This behavior isn’t exposed in the plugin’s UI—it can only be overridden via the
WC_AM_DISABLE_HOMEPAGE_CACHEconstant inwp-config.php. - Diagnosing page caching requires real HTTP requests: WP-CLI does not load
advanced-cache.php, so cache-related issues cannot be reproduced or debugged via CLI.