Nginx sets the x-fastcgi-cache header to EXPIRED a few hours after the page was first cached, whereas the cache validity is 1 week.
Nginx Config:
fastcgi_cache_path /usr/share/nginx/fastcgi_cache levels=1:2 keys_zone=phpcache:500m max_size=30g inactive=1w use_temp_path=off; fastcgi_cache_key "$scheme$request_method$host$request_uri"; fastcgi_ignore_headers Cache-Control Expires Set-Cookie; fastcgi_cache_valid 1w; server { listen 443 ssl http2; listen [::]:443 ssl http2; ... set $skip_cache 0; set $bypass_reason "NONE"; set $woocommerce "OK"; # POST requests and URLs with a query string should always go to PHP if ($request_method = POST) { set $skip_cache 0; set $bypass_reason "REQUEST_METHOD"; } if ($request_uri ~* ("/wp-admin.*|/cart.*|/panier.*|/commander.*|/checkout.*|/account.*|/myaccount.*|/addond.*|/store.*|/shop.*|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-ocations.php|sitemap(_index)?.xml|a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $skip_cache 1; set $bypass_reason "REQUEST_URI_1"; } if ( $cookie_yith_ywraq_items_in_raq != "0" ) { set $woocommerce "NOK"; } if ( $cookie_yith_ywraq_items_in_raq = "" ) { set $woocommerce "OK"; } if ( $woocommerce = "NOK" ) { set $skip_cache 1; set $bypass_reason "WOOCOMMERCE"; } if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") { set $skip_cache 1; set $bypass_reason "REQUEST_URI_2"; } if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|panier|commander") { set $skip_cache 1; set $bypass_reason "HTTP_COOKIE"; } location ~ \.php$ { fastcgi_cache_bypass $skip_cache; fastcgi_no_cache $skip_cache; fastcgi_cache phpcache; fastcgi_cache_valid 200 301 302 60m; fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503; fastcgi_cache_min_uses 1; fastcgi_cache_lock on; add_header X-FastCGI-Cache $upstream_cache_status; add_header X-FastCGI-Cache-Bypass-Reason $bypass_reason; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; fastcgi_index index.php; include fastcgi_params; } ... I don't understand why even with inactive=1w and fastcgi_cache_valid 1w I have an expired cache status.
Any ideas on what I am missing here?
Thanks
fastcgi_cache_validin thelocation ~ \.php$block at some point but it is useless now. It probably is the source of the issue. I think you may post your comment as an answer. Thanks for pointing it out!