How FastCGI cache works
FastCGI cache sits between Nginx and PHP-FPM, storing the complete HTTP response for dynamic pages:First request
When a page is requested for the first time:
- Nginx receives the request
- Request is forwarded to PHP-FPM
- PHP executes the code and generates output
- Response is cached by Nginx and served to the user
FastCGI cache can reduce server load by up to 95% for high-traffic websites.
Cache configuration
Webinoly stores the FastCGI cache in memory at/run/nginx-cache/ for maximum performance.
Global settings
Cache parameters are defined in/etc/nginx/conf.d/fastcgi.conf:
- levels=1:2: Two-level directory hierarchy for efficient file storage
- keys_zone=WORDPRESS:50m: 50MB memory for storing cache keys (metadata)
- max_size=100m: Maximum cache storage (90% of
/runfolder size by default) - inactive=7d: Cached items are removed after 7 days without access
- fastcgi_cache_valid: Cache duration by HTTP status code
200(success): 30 days- Redirects: 1 minute
- Errors: 1 minute
The cache size is automatically calculated based on your server’s RAM. A server with 2GB RAM typically gets ~180MB cache space.
Cache validity customization
Modify cache durations globally:/opt/webinoly/webinoly.conf:
WordPress cache
Webinoly includes WordPress-specific cache rules that handle common scenarios:Cache bypass rules
Certain requests automatically bypass the cache: Query strings: URLs with query parameters/wp-admin/*- WordPress admin area/xmlrpc.php- XML-RPC requests/wp-*.php- WordPress PHP files/feed/- RSS feeds*sitemap*.xml- XML sitemaps- WooCommerce pages:
/cart/,/checkout/,/my-account/
comment_author- Recent commenterswordpress_[hash]- Logged-in userswordpress_logged_in- WordPress authenticationwp-postpass- Password-protected postswordpress_no_cache- Manual cache bypass[items]_items_in_cart- WooCommerce cart[cart]_cart_hash- WooCommerce checkout
Enable cache for a site
- New site
- Existing site
Create a WordPress site with cache enabled:
Disable cache
Temporarily disable cache:Cache customization
Customize WordPress cache rules per site:Cache management
Clear cache
- Single site
- All sites
Clear cache for a specific domain:
Cache status
Check if cache is enabled:Cache: Enabled in the output.
Test cache headers
Verify cache is working:X-Cache-Status header in Nginx logs:
MISS- Content not in cacheHIT- Content served from cacheBYPASS- Cache intentionally bypassedEXPIRED- Cached content expiredUPDATING- Cache being refreshed in background
Advanced configuration
Global cache defaults
Set global WordPress cache rules in/opt/webinoly/webinoly.conf:
Custom cache rules
Create custom cache rules for specific needs:Cache warmer
Automatically pre-populate cache after clearing:Performance optimization
Background cache updates
Webinoly enablesfastcgi_cache_background_update to refresh stale cache entries in the background while serving the old cached version to users.
Cache locking
Thefastcgi_cache_lock directive ensures only one request populates the cache for a given page, preventing cache stampede:
Stale content serving
Serve stale cache if PHP-FPM is unavailable:Monitoring
Cache hit ratio
Monitor cache effectiveness in Nginx access logs:Cache size
Check current cache usage:Best practices
Do’s:
- Enable cache for high-traffic WordPress sites
- Clear cache after theme/plugin updates
- Monitor cache hit ratio regularly
- Use cache for production sites, not development
- Test cache bypass rules for dynamic content
Troubleshooting
Cache not working
-
Verify cache is enabled:
-
Check Nginx configuration:
-
Ensure
/run/nginx-cache/directory exists: -
Check cache headers in response:
Stale content issues
If users see outdated content:High cache misses
If cache hit ratio is low:- Review bypass rules (query strings, cookies)
- Check if cache size is sufficient
- Verify cache is not being cleared too frequently
- Analyze URL patterns in access logs