FRiCKLE / ngx_cache_purge

nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches.
http://labs.frickle.com/nginx_ngx_cache_purge/
Other
1.06k stars 311 forks source link

Support to purge entire zone #10

Open rahul286 opened 11 years ago

rahul286 commented 11 years ago

Thanks for good work. I have a request from me and many of my readers...

We need a purge ALL option.

Currently we can do...

fastcgi_cache_purge zone_name key

What we need to do....

fastcgi_cache_purge zone_name EVERYTHING

or may be

fastcgi_cache_flush zone_name

Use-case:

We have modified theme or deployed new codes. Entire cache becomes invalid.

As of now we need to do rm -rf on cache-location which is cumbersome and bit risky.

If a new directive gets added, that will be really helpful.

rahul286 commented 11 years ago

We have developed a WordPress plugin which uses your module and this an issue I am talking about here - https://github.com/rtCamp/nginx-helper/issues/10

rla commented 11 years ago

This would be quite nice feature!

aeroclown commented 11 years ago
            function true_purge_all(){
                    $this->unlinkRecursive(RT_WP_NGINX_HELPER_CACHE_PATH, false);
                    $this->log( "* * * * *" );
                    $this->log( "* Purged Everything!" );
                    $this->log( "* * * * *" );
            }

This needs to be changed. You are incorrectly assuming that the php user has access to the nginx cache. When using php-fpm with multiple pools that will not be the case. Nginx and php-fpm are seperate systems. This results in a permission denied error because the pool user is not the nginx user. This is not an end user configuration problem, this is an incorrect assumption that all users will use single pools owned by the user running nginx.

Maybe consider making something like this a requirement so we can hook into nginx instead of trying to recurisively unlink files with php. http://labs.frickle.com/nginx_ngx_cache_purge/

rahul286 commented 11 years ago

@aeroclown

  1. We have only 1 php pool.
  2. When we run into permission issue, we add PHP process user to nginx users' group.

To avoid all such workarounds, it will be great for a module to directly have a purge all at nginx-level only.

rahul286 commented 11 years ago

@aeroclown by the way I am not developer of ngx_cache_purge module. This issue is more like feature request to the developer.

aeroclown commented 11 years ago

Oops, I was looking at the wrong project when I posted this, I was looking at the nginx helper for wordpress or is this the same. I was suggesting that they add an ngx purge or cache module for nginx as a requirement instead of what they are doing with a recursive unlink.

Thats a good suggestion though, I was doing the group mods in reverse. I feel rather stupid that I did it the other way.

rahul286 commented 11 years ago

@aeroclown nginx-helper is here - https://github.com/rtCamp/nginx-helper

We are developer of that wordpress plugin. We wish purge-all to be handled by nginx-module that is why I posted a request here.

here commented 10 years ago

see potential workaround using http headers https://drupal.org/node/2094425

dbu commented 10 years ago

this would sound like a limited variant of the varnish ban method. ban in varnish can invalidate cache based on regular expression matching of any header. the problem is that this operation could potentially take a long time, thus ban are just added to a list and checked on match, and then you activate a process that throws away cache entries if they match a ban while varnish is not too busy.

yazeed commented 10 years ago

Any hope on this?

chredd commented 9 years ago

+1 on this feature.

frankyw commented 9 years ago

+2 on this feature