# RunCache: NGINX FastCGI cache configuration. # Include this file in the http context, e.g. inside /etc/nginx/conf.d/. # Bugs or questions? Email support@runcloud.io. # This file contains http-context directives only. fastcgi_cache_path {{DOCUMENT_ROOT}}wp-content/cache/runcache/{{HOST}}/fastcgi levels=1:2 keys_zone={{CACHE_ZONE}}:10m max_size=1g inactive=8h use_temp_path=off; fastcgi_cache_key '$scheme$request_method$host$request_uri'; # Bypass cache for mandatory authentication/session cookies. map $http_cookie ${{SITE_CACHE_VAR}}_logged_in { default 0; ~*wordpress_logged_in 1; ~*wordpress_sec_ 1; ~*wp-postpass 1; ~*comment_author 1; ~*wp-settings- 1; } # Only GET requests may be cached. PHP applies all configurable query rules. map $request_method ${{SITE_CACHE_VAR}}_no_cache_method { default 1; GET 0; } # Query compatibility rules are evaluated by PHP after a cache miss. # Bypass cache for admin, auth, cron, REST, feed, and WooCommerce paths. map $uri ${{SITE_CACHE_VAR}}_no_cache_uri { default 0; ~*^/\.well-known 1; ~*^/wp-admin 1; ~*^/wp-login\.php 1; ~*^/wp-cron\.php 1; ~*^/xmlrpc\.php 1; ~*^/wp-signup\.php 1; ~*^/wp-activate\.php 1; ~*^/wp-comments-post\.php 1; ~*^/(cart|checkout|my-account) 1; ~*^/wp-json 1; ~*^/feed/? 1; ~*(^|/).*sitemap.*\.xml$ 1; } # Browser and visitor-IP rules are evaluated by PHP after a cache miss. map $http_user_agent ${{SITE_CACHE_VAR}}_no_cache_agent { default 0; } map $remote_addr ${{SITE_CACHE_VAR}}_no_cache_ip { default 0; } # Fallback status value when no cache lookup happened. map $upstream_cache_status $runcache_fastcgi_status_value { "" "BYPASS"; default $upstream_cache_status; } # Expose X-RunCache-Status only when FastCGI caching is active. map $runcache_fastcgi_disabled $runcache_fastcgi_status_header { 1 ""; 0 $runcache_fastcgi_status_value; } # Expose X-RunCache-Type only when FastCGI caching is active. map $runcache_fastcgi_disabled $runcache_fastcgi_type_header { 1 ""; 0 "Nginx FastCGI"; }