FastCGI cache in Nginx only caches PHP responses. To efficiently cache WordPress pages, it’s recommended to use a plugin or configure caching rules to control what gets stored and when.
That’s because this conf is in the template. These ones are too aggressive (comment_author and wordpress_[a-f0-9]+).
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart|woocommerce_cart_hash|PHPSESSID") {
set $no_cache 1;
}
You could replace it with this:
if ($http_cookie ~* "wordpress_logged_in_|wp-postpass_|wordpress_no_cache|woocommerce_items_in_cart|woocommerce_cart_hash") {
set $no_cache 1;
}
The problem here is that your site is always sending a cookie header using PHPSESSID. I suspect the issue is caused by a plugin, because by default WordPress doesn’t send that kind of cookie for anonymous users.
Headers on your site, without sending the PHPSESSID cookie, show the FastCGI cache as a HIT:
So, in your case, I would remove only PHPSESSID and keep the others that are used for logged-in users. I don’t know which plugins are using that cookie, so you should test it just in case.
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart|woocommerce_cart_hash") {
set $no_cache 1;
}
As I said, you can remove PHPSESSID from Nginx configuration but I don’t know how it could affect to the plugin:
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart|woocommerce_cart_hash") {
set $no_cache 1;
}
Too risky, I might end up with something that doesn’t work. Basically, it’s pointless to have the fastCGI cache if it can be bypassed so easily by something we have no control over.