I have fastcgi cache enabled on the site with these settings:
fastcgi_cache_path /etc/nginx/cache/kn levels=1:2 keys_zone=kn_cz:50m inactive=10m;
if ($http_cookie ~* "sssp_session|szncmpone") {
set $no_cache 1;
et $skip_reason "${skip_reason}-http_cookie";
}
location ~ \.php$ {
if ($args ~ nginx_helper_action=purge|action=purge_cache) {
fastcgi_pass unix:/run/php/php8.3-fpm.sock;
}
fastcgi_pass unix:/run/php8.3-fpm-kn.sock;
include snippets/fastcgi-php.conf;
fastcgi_cache kn_cz;
fastcgi_cache_valid 200 301 302 2h;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_ignore_headers Cache-Control Expires Set-Cookie ;
fastcgi_cache_use_stale error timeout updating invalid_header http_500 http_503;
fastcgi_cache_min_uses 1;
fastcgi_cache_lock on;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
add_header X-FastCGI-Cache $upstream_cache_status;
}
We generate content depending on whether sssp_session cookies are active or not. If the sssp_session cookie appears, the cache is disabled.
Is there a way to set the cache to be created for both cases?
- cache with cookie sssp_session
- cache without cookie sssp_session
I tried several ways but it always showed the same cache.