rtCamp / nginx-helper

Nginx Helper for WordPress caching, permalinks & efficient file handling in multisite
https://wordpress.org/plugins/nginx-helper/
224 stars 117 forks source link

purge_all permissions problem #283

Open thend20 opened 1 year ago

thend20 commented 1 year ago

purge_all attempts to recursively remove all files under the nginx cache dir. However, when nginx is running as user nginx and PHP is ran as php, the purge_all does not have adequate permissions to clear the cache.

I would suggest an alternate purge_all which does a GET call to nginx to a purgeall endpoint and allow the user setup a location block for /purgeall. This could use the purge_all feature of the fastcgi_cache_purge module..for example.

        location ~ /purgeall {
            fastcgi_pass         php;
            fastcgi_cache        WORDPRESS;
            fastcgi_cache_purge  PURGE purge_all from 127.0.0.1;
        }

This could be accomplished by letting the user use the original unlink_recusive method, or by using this new method using a simple GET call

+            $_url_purge = home_url() . '/purgeall';
+            $this->log( '- Purging URL | ' . $_url_purge );
+            $this->do_remote_get( $_url_purge );