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

Posted by tOmasEn (Guest)
on 2009-12-19 15:25
(Received via mailing list)
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.
Posted by Kruglov Eugenie (Guest)
on 2009-12-19 15:25
(Received via mailing list)
rm -rf /data/nginx/proxy_cache2/*
Posted by Piotr Sikora (Guest)
on 2009-12-19 15:25
(Received via mailing list)
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] http://labs.frickle.com/nginx_cache_purge

Best regards,
Piotr Sikora < piotr.sikora@frickle.com >
Posted by tOmasEn (Guest)
on 2009-12-19 15:25
(Received via mailing list)
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?
Posted by Piotr Sikora (Guest)
on 2009-12-22 15:05
(Received via mailing list)
> 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 Sikora < piotr.sikora@frickle.com >
Posted by Radek (Guest)
on 2010-09-02 10:22
(Received via mailing list)
Try to use my script on site:
http://linux-sysadmin.org/2010/08/nginx-invalidation-purging-content/

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,30833,126252#msg-126252
Posted by Roast (Guest)
on 2010-09-02 10:34
(Received via mailing list)
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 <nginx-forum@nginx.us> wrote:
> Try to use my script on site:
> http://linux-sysadmin.org/2010/08/nginx-invalidation-purging-content/
>
> Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,30833,126252#msg-126252
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.