nginx-helper icon indicating copy to clipboard operation
nginx-helper copied to clipboard

purge_all permissions problem

Open thend20 opened this issue 3 years ago • 7 comments

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 );

thend20 avatar Sep 14 '22 19:09 thend20

It’s remarkable that this request, first raised in 2022, is still open as an enhancement.

The Nginx configuration shared by @thend20 actually belongs to the ngx_cache_purge module FRiCKLE/ngx_cache_purge

ngx_cache_purge is an Nginx module that adds the ability to purge content from FastCGI, proxy, SCGI, and uWSGI caches.

This module went unmaintained for years until torden forked it and released updates (torden/ngx_cache_purge ). Today, it remains in active use—not just by EasyEngine, but also by numerous control panels, hosting providers, and Nginx stacks. It has even been forked under the Community NGINX Modules account (nginx-modules/ngx_cache_purge).

GridPane submitted a PR (#344) to enable the use of PURGE/* via:

curl -X PURGE https://url/purgeall

Unfortunately, only parts of that PR were adopted. Credit was initially omitted, then belatedly attributed to GridPane after being called out—but the PURGE/* functionality, which is valuable to the broader community, was never merged.

As a result, if you want to run the latest ngx_cache_purge module on a WordPress site and have a reliable way to purge the entire cache, the only maintained option is to use GridPane’s fork: 👉 gridpane/nginx-helper

Given the history here, can you explain why the PURGE/* functionality was excluded and whether there are plans to reconsider its inclusion?

jordantrizz avatar Sep 18 '25 09:09 jordantrizz

Hi @jordantrizz ,

Thank you for following up and for summarizing the background here, that’s really helpful context.

I see that the PR (#344) introduced several useful updates, some of which were merged, while the PURGE/* functionality wasn’t included at the time. Since there isn’t a clear record publicly explaining the reasoning behind that decision, I’ve raised this internally to confirm whether it was due to technical, security, or compatibility concerns.

We’ll review the original discussion, revisit whether PURGE/* can be supported safely in the current setup, and follow up here once we have more details to share.

Appreciate your patience and the effort you’ve put into keeping this conversation active, it helps ensure valuable contributions like this get the attention they deserve.

Neha93517 avatar Oct 09 '25 06:10 Neha93517

Hi @jordantrizz, Thank you for your patience and for continuing to bring attention to this enhancement.

Following internal discussions, we’ve revisited the original decision and implemented the PURGE/* functionality based on your earlier contribution.

This update will be included in the next release of the Nginx Helper plugin. Once it’s live, the changelog will reflect the addition so it’s clear to everyone following this thread.

We appreciate your detailed feedback and persistence in advocating for improvements that benefit the wider community, it’s been instrumental in getting this enhancement finalized.

Neha93517 avatar Oct 10 '25 07:10 Neha93517

Is the nginx /purgeall feature already add to the "Purge entire cache" button? As it is not the behaviour i'm seeing. It still seems to purge the cache using php instead of using the nginx location of /purgeall.

2025/10/28 13:18:39 [error] 942231#0: *531 FastCGI sent in stderr: "PHP message: PHP Warning: opendir(/home/peps/.nginx_cache/peps.xxxxxxxxxx.nl/5): Failed to open directory: Permission denied in /home/peps/domains/peps.xxxxxxxx.nl/public_html/wp-content/plugins/nginx-helper/admin/class-purger.php on line 1225; PHP message: PHP Warning: opendir(/home/peps/.nginx_cache/peps.xxxxxxxxx.nl/9): Failed to open directory: Permission denied in /home/peps/domains/peps.xxxxxxxxxx.nl/public_html/wp-content/plugins/nginx-helper/admin/class-purger.php on line 1225; PHP

PepsAi avatar Oct 28 '25 12:10 PepsAi

We appreciate your detailed feedback and persistence in advocating for improvements that benefit the wider community, it’s been instrumental in getting this enhancement finalized.

Thank you, the community appreciates you pushing this through!

jordantrizz avatar Oct 29 '25 15:10 jordantrizz

Very welcome @jordantrizz , would really like to see this fixed, hope it helps! :)

I added additional info here before receiving your feedback above, it might help further:

https://wordpress.org/support/topic/purge-entire-cache-not-working-via-ngx_cache_purge-module/

PepsAi avatar Oct 30 '25 09:10 PepsAi

Hi @PepsAi , Thanks for the additional details, that’s really helpful! The /purgeall support has already been implemented, but it hasn’t been included in a public release yet. Our team is aware and working on preparing it for an upcoming release. While there’s no exact timeline to share just yet, we’ll keep this thread updated once it’s available.

Neha93517 avatar Nov 03 '25 11:11 Neha93517