rtCamp / nginx-helper

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

Add support for the torden branch of `ngx_cache_purge` #306

Open gnif opened 1 year ago

gnif commented 1 year ago

The torden branch has support for purge_all with the following directive added to the nginx configuration:

location = /purgeall {
    fastcgi_pass        unix:/dev/null;
    fastcgi_cache       WORDPRESS;
    fastcgi_cache_purge PURGE purge_all from 127.0.0.1;
}

This makes it possible to purge the cache on systems where Nginx is running as a different user to the PHP process.

Note, the unix:/dev/null in the above example is not a placeholder, the module needs fastcgi_pass set to something valid or it will not function, even though it never uses the value provided.

2023-06-13-104906_544x272_scrot

gridpane commented 3 months ago

We are using this module, and have a helper mu plugin installed with much the same code... this really would be great the core plugin

gridpane commented 3 months ago

Ive pulled this into my fork, alongside working on sockets and some other things, ive adjusted this to run a php check for php5.5+ since one of the curl functions requires that, but nginx helper is set for 5.4+

Seems this fork is taking code to I wrote with Jebat 5 years ago and bringing it into nginx helper

https://github.com/JeffCleverley/NginxFastCGICachePurger

gridpane commented 3 months ago

I have pulled in code from this, combined it with other work we have been doing on Redis sockets, db, and ACLs, and setting everything to be configurable by constants:

https://github.com/gridpane/nginx-helper

I plan to make a PR back here once finished testing, ive accredited gnif in readme etc, but also added guards for php version and fixed all the conflicts.

Was working on the redis connections and saw this waiting with conflicts, figured since we use this code anyway made sense to try to get it all done.

Screenshot 2024-06-29 at 22 26 31 Screenshot 2024-06-29 at 22 27 11