# Purge whole cache zone

**URL:** <https://www.ruby-forum.com/t/purge-whole-cache-zone/229559>\
**Category:** NGINX\
**Created:** [January 1, 2013, 3:12pm UTC](https://www.ruby-forum.com/t/purge-whole-cache-zone/229559 "2013-01-01T15:12:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oleksandr-shb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/4af34b/32.png) [@oleksandr-shb](https://www.ruby-forum.com/u/oleksandr-shb)\
**Post date:** [January 1, 2013, 3:12pm UTC](https://www.ruby-forum.com/t/purge-whole-cache-zone/229559/1 "2013-01-01T15:12:50Z")

</div>

Hi, I am interested if it is possible to invalidate whole cache zone.  
Now it  
is possible to invalidate single cache item using cache key and third  
party  
module Cache Purge. What I need is to remove all cache items when  
hitting  
some location. So far the ideas are next:

1. remove cache folder, but then you need to restart nginx.
2. create several cache\_zones and use the one stored with the name  
stored in  
memcache. So when cache needs to be invalidated the backend will update  
cache\_zone name record stored in memcache. It seems to be like a  
possible  
way, but have no idea how to implement it.

Posted at Nginx Forum:

> **[Purge whole cache zone](https://forum.nginx.org/read.php?2,234605,234605#msg-234605)**
>
> Hi, I am interested if it is possible to invalidate whole cache zone. Now it is possible to invalidate single cache item using cache key and third party module Cache Purge. What I need is to remove all cache items when hitting some location. So far...

---

<div class="post-metadata">

**Author:** ![oleksandr-shb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/4af34b/32.png) [@oleksandr-shb](https://www.ruby-forum.com/u/oleksandr-shb)\
**Post date:** [January 1, 2013, 3:40pm UTC](https://www.ruby-forum.com/t/purge-whole-cache-zone/229559/2 "2013-01-01T15:40:17Z")

</div>

Sorry, folks my question is a duplicate of this thread  
[http://forum.nginx.org/read.php?2,30833,32763#msg-32763](http://forum.nginx.org/read.php?2,30833,32763#msg-32763) (solution). So,  
the  
solution is to remove cache folder and kill nginx processes. Not killing  
processes caused troubles with blank pages for me.

# rm -rf /data/nginx/proxy\_cache2 && killall -HUP nginx

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,234605,234606#msg-234606](http://forum.nginx.org/read.php?2,234605,234606#msg-234606)

---

<div class="post-metadata">

**Author:** ![oleksandr-shb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/4af34b/32.png) [@oleksandr-shb](https://www.ruby-forum.com/u/oleksandr-shb)\
**Post date:** [January 1, 2013, 9:30pm UTC](https://www.ruby-forum.com/t/purge-whole-cache-zone/229559/3 "2013-01-01T21:30:12Z")

</div>

Hello!

On Tue, Jan 01, 2013 at 09:39:32AM -0500, oleksandr-shb wrote:

> Sorry, folks my question is a duplicate of this thread  
> [http://forum.nginx.org/read.php?2,30833,32763#msg-32763](http://forum.nginx.org/read.php?2,30833,32763#msg-32763) (solution). So, the  
> solution is to remove cache folder and kill nginx processes. Not killing  
> processes caused troubles with blank pages for me.
> 
> # rm -rf /data/nginx/proxy\_cache2 && killall -HUP nginx

Correct solution would be to remove all items (subdirectories  
and/or files) within the cache folder, not the cache folder  
itself.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.

---

<div class="post-metadata">

**Author:** ![oleksandr-shb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/4af34b/32.png) [@oleksandr-shb](https://www.ruby-forum.com/u/oleksandr-shb)\
**Post date:** [January 2, 2013, 9:26am UTC](https://www.ruby-forum.com/t/purge-whole-cache-zone/229559/4 "2013-01-02T09:26:20Z")

</div>

Is it possible to have each server{} block write to it’s own cache  
directory? Or otherwise identify cached pages by server{} block?

The aim is to make it easy to clear all cached pages for a specific site  
on  
a box hosting multiple sites.

---

<div class="post-metadata">

**Author:** ![oleksandr-shb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/4af34b/32.png) [@oleksandr-shb](https://www.ruby-forum.com/u/oleksandr-shb)\
**Post date:** [January 2, 2013, 9:47am UTC](https://www.ruby-forum.com/t/purge-whole-cache-zone/229559/5 "2013-01-02T09:47:22Z")

</div>

On Jan 2, 2013, at 12:25 , Tom Barrett wrote:

> Is it possible to have each server{} block write to it’s own cache directory? Or  
> otherwise identify cached pages by server{} block?
> 
> The aim is to make it easy to clear all cached pages for a specific site on a  
> box hosting multiple sites.

proxy\_cache\_path /path/to/cache/server1 keys\_zone=SERVER1:10m;

server {  
server\_name [server1.domain.com](http://server1.domain.com);  
proxy\_cache SERVER1;  
…  
}

proxy\_cache\_path /path/to/cache/server2 keys\_zone=SERVER2:10m;

server {  
server\_name [server2.domain.com](http://server2.domain.com);  
proxy\_cache SERVER2;  
…  
}
