Nginx Helper, as you mentioned relies on a custom compile of Nginx, which can take some work to install and keep updated.
Cache Sniper for Nginx is a free WordPress plugin that can invalidate the FastCGI Cache, and works fine with the vanilla Nginx you get from doing a yum install
.
Cache Sniper for Nginx can clear the entire cache:
You can also clear the cache for specific pages, and automatically clear the page cache when it's updated or receives a comment.
In your Nginx conf, you probably have fastcgi_cache
configured similar to this:
fastcgi_cache_path /var/lib/nginx/webshop levels=1:2 keys_zone=WEBSHOP:1440m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
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;
}
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$ { # this location block already exists, but you're adding lines to it
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_keep_conn on;
fastcgi_index index.php;
# The next few lines are new:
fastcgi_cache WEBSHOP;
fastcgi_cache_methods GET HEAD;
fastcgi_cache_valid 200 100m;
fastcgi_cache_bypass $no_cache;
fastcgi_no_cache $no_cache;
}
# ...
}
In order to use the plugin, you'll have to do a few things:
Set the fastcgi_cache_key
in your Nginx conf to:
"$scheme$request_method$host$request_uri"
(Nginx has to calculate the URL's hash the same way the plugin does.)
Get the fastcgi_cache_path
path (in this case: /var/lib/nginx/webshop
) and paste it into the plugin settings. This is the Linux filesystem path where all the cached HTML is stored.
Get the levels
(in this case: 1:2
) and also paste this into the plugin settings. This is just last few characters of the URL hash to organize cached pages into subfolders. For example:
/var/lib/nginx/webshop/z/xy/qrstuvwxyz
(You can find the Cache Sniper for Nginx plugin settings under Tools)