Setting Up WP Rocket Caching Plugin for WordPress
WP Rocket is a paid caching plugin ($59/year per site), the de-facto standard for WordPress. Includes page caching, CSS/JS minification and concatenation, lazy image loading, preloading, CDN integration.
Key Settings
Cache: enable separate caching for mobile devices (not needed if theme is responsive, needed if separate mobile theme). Cache TTL—10 hours for content sites, 1 hour for e-commerce with dynamic prices.
File Optimization: CSS and JS minification—enable carefully, test visually. CSS concatenation—only if no HTTP/2. JS concatenation—almost never enable, breaks scripts.
Media: lazy load images—enable. Replace YouTube/Vimeo thumbnails—enable, replaces iframe with preview, reduces requests to external resources.
Preloading: Preload Cache—enable, WP Rocket automatically warms cache after purge. Preload Links—enable, preloads pages on hover.
Advanced Rules:
# Never Cache URLs
/cart/
/checkout/
/my-account/
/wc-api/
/.*/feed/
# Never Cache Cookies
woocommerce_cart_hash
woocommerce_items_in_cart
wordpress_logged_in_
# Always Purge URLs
/blog/
CDN Integration
In the CDN section, specify CDN zone URL (Cloudflare, BunnyCDN, KeyCDN). WP Rocket replaces static file paths with CDN URLs.
For Cloudflare—use WP Rocket + Cloudflare Add-On: plugin automatically purges Cloudflare cache on publish.
// Programmatic WP Rocket cache clearing
if (function_exists('rocket_clean_domain')) {
rocket_clean_domain(); // entire site
}
if (function_exists('rocket_clean_post')) {
rocket_clean_post($post_id); // specific page
}
WP Rocket and WooCommerce
WP Rocket automatically excludes /cart/, /checkout/, /my-account/ from cache. Enable Fragment Caching for cart: cart widget in header updates dynamically via AJAX without breaking cache.
What NOT to Enable
- Remove query strings—rarely useful, may break some plugins
- Combine Google Fonts—Google Fonts no longer recommended via Google CDN (GDPR), better to self-host
- Defer JS—test carefully, breaks plugins dependent on jQuery on load
Timeline
WP Rocket installation and basic setup with testing—3–4 hours.







