What is the correct way to flush/delete proxy_cache without restart nginx?

what is the correct way to flush/delete proxy_cache without restart
nginx?

kill -HUP doesn’t seems to work.

I tried use script like
find /data/nginx/proxy_cache2 -type f -exec rm -f {};

but the file still there, it seems nginx have locked the cache files.

rm -rf /data/nginx/proxy_cache2/*

As far as I know there is no official way to flush / empty cache.

You can either:
a) purge whole cache using “rm -rf /data/nginx/proxy_cache2” (this will
somehow invalidate all cache files, because nginx won’t be able to open
them
anymore),
b) purge selected pages using cache_purge patch [1].

[1] FRiCKLE Labs / nginx / cache_purge

Best regards,
Piotr S. < [email protected] >

rm -rf /data/nginx/proxy_cache2
Doesn’t that will affect nginx keep creating the cache? I mean doesn’t
that
stop proxy cache working since directory doesn’t existed?

rm -rf /data/nginx/proxy_cache2
Doesn’t that will affect nginx keep creating the cache? I mean doesn’t
that
stop proxy cache working since directory doesn’t existed?

No, it won’t, because nginx will re-create directory when needed. This
could
potentialy disrupt work of cache helpers (cache manager & cache loader),
so
just to be on the safe side you could run this instead:

rm -rf /data/nginx/proxy_cache2 && killall -HUP nginx

Best regards,
Piotr S. < [email protected] >

Try to use my script on site:
http://linux-sysadmin.org/2010/08/nginx-invalidation-purging-content/

Posted at Nginx Forum:

If you want to clear the cache, you can do it like this:

[root@… ~]#cd {proxy_cache_path}
[root@… ~]#find -type f -exec rm -f {} ;

If you want to clear a specified item, you can use this module:
http://labs.frickle.com/nginx_ngx_cache_purge/

On Thu, Sep 2, 2010 at 4:22 PM, Radek [email protected] wrote:

Try to use my script on site:
http://linux-sysadmin.org/2010/08/nginx-invalidation-purging-content/

Posted at Nginx Forum:
Re: what is the correct way to flush/delete proxy_cache withoutrestartnginx?