Question

FastCGI always MISS when Wordfence is enabled.

Hello, yesterday i installed wordfence and then eanbled Nginx FastCGI. but FastCGI isnt working. all pages are maked as MISS.

then i disabled wordfence and everything is fine again. i contacted with wordfence auther but till now no answer.

is there anyone using Nginx FastCGI and wordfence together??

my FastCGI setup is pretty basic.

fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_cache_use_stale error timeout invalid_header http_500;
#fastcgi_cache start
set $no_cache 0;

# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
        set $no_cache 1;
}   
if ($query_string != "") {
        set $no_cache 1;
}   

# Don't cache uris containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
        set $no_cache 1;
}   

# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
        set $no_cache 1;
} 

 location ~ \.php$ {
                include snippets/fastcgi-php.conf;
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
                fastcgi_cache WORDPRESS;
                fastcgi_cache_valid 200 60m;
                fastcgi_cache_bypass $no_cache;
                fastcgi_no_cache $no_cache;
}
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@newbie

FastCGI Caching does full-page caching, which means changes to output won’t take until the cache is flushed for the requested URI, or entirely (in some cases). Unfortunately, the plugin that used to work with NGINX to aid in flushing the cache has not been updated in a while which makes this a manual process.

Some plugins may work with FastCGI Cache, others may not – there’s really no guarantee as to what will and won’t work unfortunately.

I’ve never ran in to issues with FastCGI (without caching) and WordFence – though I rarely use FastCGI Caching unless there’s a viable solution readily available for flushing the cache and it’s tested across the platform to ensure that it works entirely. As of right now, it’s a manual process, or a custom solution needs to be implemented to perform the flushing.

Enabling FastCGI caching, as you’re experiencing, can have some odd and unintended results from time to time, which is why you really need to test it 100% in development before using it in production.