Nginx helper + fastcgi_cache + purge


#1

Hello, I use the nginx_helper plugin for wordpress with nginx and the fastcgi_cache module. Caching works great, also the purge if I edit a post via wordpress. But I didnt found a solution to purge the complete site. If I try the buttons “purge cache” or “purge entire cache” I dont get any errors, but the cache is still available. Is there any solutions? Every site in my configuration has his own fastcgi_cache_path so it would be no problem if I delete the complete directory. Any help is welcome


#2

This toplevel menu should work for you, clearing entire cache: http://prntscr.com/g95rj4


#3

Unfortunately, no

here is my nginx site config:

fastcgi_cache_path /dev/shm/nginx/domainname levels=1:2 keys_zone=domainname:1m max_size=2m inactive=30d; server { listen xx.xx.xx.xx:80;

    listen xx.xx.xx.xx:443 ssl http2;
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate /var/www/clients/client0/web2/ssl/domainname-le.crt;
    ssl_certificate_key /var/www/clients/client0/web2/ssl/domainname-le.key;
    server_name domainname www.domainname;
    root   /var/www/domainname/web/;
    index index.html index.htm index.php index.cgi index.pl index.xhtml;
    location ~ /\.(?!well-known/acme-challenge/) {
        deny all;
        access_log off;
        log_not_found off;
    }
    location ~ \.php$ {
        try_files /37437c796bfb3d32661a602f0089e1c8.htm @php;
    }
    location ~ /\.well-known/acme-challenge/ {
               root /usr/local/ispconfig/interface/acme/;
               index index.html index.htm;
               try_files $uri =404;
    }
    location @php {
                try_files $uri =404;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass unix:/var/run/php/web2.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME
                $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
                fastcgi_cache_bypass $no_cache;
                fastcgi_no_cache $no_cache;
                fastcgi_cache domainname;
                fastcgi_cache_valid 200 301 302 30d;
                fastcgi_cache_use_stale updating error timeout invalid_header http_500;
                expires 30d;
                fastcgi_cache_valid 404        1s;
                fastcgi_cache_min_uses          1;
                fastcgi_ignore_headers Cache-Control Expires;
                fastcgi_pass_header Set-Cookie;
                fastcgi_pass_header Cookie;
                set $no_cache 0;
                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;
                }
                if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
                  set $no_cache 1;
                }
    }
    location / {
                                    try_files $uri $uri/ /index.php?$args;
    }
                           rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    location ~ /purge(/.*) {
                fastcgi_cache_purge domainname "$scheme$request_method$host$1";
    }
    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
                  access_log        off;
                  log_not_found     off;
                  expires           max;
                  add_header Cache-Control "public";
    }

}

Maybe you can give me your config?


#4

Here the default EE configuration with fastcgi_cache :

set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
  set $skip_cache 1;
}
if ($query_string != "") {
  set $skip_cache 1;
}
# Don't cache URL containing the following segments
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|wp-.*.php|index.php|/feed/|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
  set $skip_cache 1;
}
# Don't use the cache for logged in users or recent commenter or customer with items in cart
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_items_in_cart") {
  set $skip_cache 1;
}
# Use cached or actual file if they exists, Otherwise pass request to WordPress
location / {
  try_files $uri $uri/ /index.php?$args;
}
location ~ ^/wp-content/cache/minify/(.+\.(css|js))$ {
  try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;
}
location ~ \.php$ {
  try_files $uri =404;
  include fastcgi_params;
  fastcgi_pass php7;
  fastcgi_cache_bypass $skip_cache;
  fastcgi_no_cache $skip_cache;
  fastcgi_cache WORDPRESS;
}
location ~ /purge(/.*) {
  fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
  access_log off;
}

#5

I have the same problem! Not worked purge of Redis CACHE.

When i push in WP admin - it is not effective. Need use: redis-cli flushall

And after it - all is work! How to fix it? Thanks.

P.S. in redis monitor i found different betwen HTTP and HTTPS

    1505517802.832085 [0 127.0.0.1:50400] "expire" "domain-cache:httpsGETdomain.net/transport/perevozka-generalnyh-gruzov/" "6h"
    1505517826.114175 [0 127.0.0.1:50412] "DEL" "domain-cache:httpGETdomain.net/"
    1505517826.118903 [0 127.0.0.1:50412] "DEL" "domain-cache:httpGETdomain.net/author/admin/"
    1505517826.120795 [0 127.0.0.1:50412] "DEL" "domain-cache:httpGETdomain.net/news-categories/novosti-mir/"
    1505517846.485241 [0 127.0.0.1:50426] "select" "0"
    1505517846.485283 [0 127.0.0.1:50426] "get" "domain-cache:httpsGETdomain.net/news/tranzitnaya-dostavka/"
    1505517847.006222 [0 127.0.0.1:50432] "select" "0"
    1505517847.006259 [0 127.0.0.1:50432] "get" "domain-cache:httpsGETdomain.net/ds-comf/ds-form/formscss.php"

#6