Cache Exclusions & Advanced Rules
Advanced Rules provide granular control over which pages/content get cached and which assets get optimized.
Cache Exclusion Rules
Cache exclusions prevent specific URLs from being cached.
When to Use Exclusions
Exclude pages that:
- Require dynamic content per user (login pages, account dashboards)
- Show different content based on cookies/sessions
- Have time-sensitive information
- Should always be fresh (support pages, pricing)
Common Exclusion Patterns
/wp-admin/*
/wp-login.php
/wp-cron.php
/my-account/*
/cart/*
/checkout/*
/?p=
/?s=*
/reset-password*
/confirm-email*
Adding Exclusions
- Go to Performance Toolkit → Advanced Rules (if available) or Cache settings
- Find Cache Excluded URLs section
- Add one URL pattern per line
- Use wildcards (
*) for flexible matching - Click Save changes
Exclusion Rule Syntax
Exact Match
/special-page/
Excludes only /special-page/ exactly.
Wildcard Pattern
/blog/*/comments
Excludes /blog/article-1/comments, /blog/article-2/comments, etc.
Full Directory
/my-account/*
Excludes all URLs under /my-account/: /my-account/, /my-account/settings/, etc.
Query String Match
/?s=*
Excludes search results (URLs with ?s=query).
Asset Minification Exclusions
Prevent specific CSS/JS files from being minified or combined.
CSS Exclusions
Go to File Optimization → Minify external CSS files → Exclusions
Examples:
bootstrap
critical.css
/wp-content/plugins/woocommerce/*
JavaScript Exclusions
Go to File Optimization → Minify external JS files → Exclusions
Examples:
jquery-core
analytics.js
/wp-content/themes/my-theme/js/critical.js
Why Exclude Specific Assets?
- Plugin conflicts — minified CSS breaks styling
- Conditional loading — script shouldn't be combined
- Critical rendering path — inline critical CSS/JS separately
- Third-party — external ads/analytics with their own delivery
Combining Cache Exclusions
Exclude Multiple URL Patterns
Enter multiple patterns in the exclusion textarea:
/wp-admin/*
/wp-login.php
/wp-json/*
/my-account/*
/cart/*
/checkout/*
/?s=*
/password-reset*
/add-to-cart*
Line breaks between entries.
Testing Exclusions
After adding exclusion:
- Clear cache — go to Tools, clear all cache
- Visit excluded URL — should display correctly
- Visit non-excluded URL — should be cached
- Check console — look for JavaScript errors
- Test interactions — ensure functionality works
Advanced Rule Examples
E-Commerce Site (WooCommerce)
# Never cache
/wp-admin/*
/wp-login.php
/?s=*
/my-account/*
/cart/*
/checkout/*
/?add-to-cart=*
/?remove_item=*
/?post_type=product
Blog with Members Plugin
# Public pages cache
/
# Never cache
/wp-admin/*
/wp-login.php
/members/*
/profile/*
/?s=*
/?paged=*
Agency/Services Site
# Cache most pages
/
# But not these
/wp-admin/*
/wp-login.php
/contact-form*
/?s=*
/thank-you*
/callback*
Asset Exclusion Examples
CSS Exclusions
# WooCommerce styles (may break if minified)
woocommerce-general
woocommerce-layout
# Critical CSS (already optimized)
critical.css
inline-critical
# Theme-specific
/wp-content/themes/*/css/critical.css
JavaScript Exclusions
# jQuery (often required early)
jquery-core
jquery-migrate
# Analytics (has own minification)
google-analytics
gtag
# Form plugins
/wp-content/plugins/gravity-forms/*
/wp-content/plugins/cf7/*
Troubleshooting Exclusions
Exclusion not working
- Check syntax — did you type the URL correctly?
- Check wildcards —
*expands correctly? - Leading slashes — most patterns start with
/ - Clear cache — changes don't apply to old cache
- Save changes — did you click Save?
Too many exclusions defeating caching
If you have 20+ exclusion rules:
- Review which are truly necessary
- Only exclude user-specific or dynamic pages
- Cache more aggressively and fix issues with specifics
- Test thoroughly before expanding exclusions
Site broken after exclusions saved
- Clear cache and do hard refresh (Ctrl+Shift+R)
- Check browser console for JavaScript errors
- Remove the last exclusion added and test
- Add back one at a time to find culprit
Performance Impact
Proper exclusion rules:
- Maintain cache hit rate — don't over-exclude
- Keep pages fresh — exclude truly dynamic content
- Prevent issues — exclude problematic pages/assets
Best Practices
- ✅ Exclude URLs with query parameters (
?s=,?paged=) - ✅ Exclude admin and login pages
- ✅ Exclude user-specific pages (cart, account, profile)
- ✅ Start with minimal exclusions; add as needed
- ✅ Test before deploying to production
- ✅ Document why each exclusion exists
- ✅ Review quarterly; remove unnecessary exclusions
- ❌ Don't over-exclude (defeats caching)
- ❌ Don't exclude entire site (pointless)
- ❌ Don't exclude low-traffic pages (not worth it)
Regular Configuration Review
Quarterly:
- Review exclusion list
- Remove rules no longer needed
- Add new patterns for new features
- Test after any significant plugin/theme updates
- Monitor cache hit rate trends
Advanced: Custom Rules (if Available)
Some configurations allow custom cache rules:
- Cache this URL for 1 day (vs default TTL)
- Don't cache this URL ever
- Cache but bypass CDN
- Cache and serve stale on origin error
Check Advanced Rules section for these options if available.
Related Documentation
- See Cache page for cache TTL and size settings
- See File Optimization for asset-specific rules
- See System Status for cache hit rate monitoring
- See Troubleshooting section if having issues
Advanced rules put you in control of exactly what gets cached and optimized for your specific site's needs.