# FRiCKLE Labs & yo.se pres. ngx\_cache\_purge

**URL:** <https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369>\
**Category:** NGINX\
**Created:** [January 10, 2010, 11:36pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369 "2010-01-10T23:36:19Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [January 10, 2010, 11:36pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/1 "2010-01-10T23:36:19Z")

</div>

Hello,  
ngx\_cache\_purge is a module which adds ability to purge content from  
FastCGI  
and proxy caches. This is rewrite of well-tested cache\_purge patch  
(kindly  
funded by yo.se), so hopefully this short introduction is enough 😉

You can download it at usual place:  
[http://labs.frickle.com/nginx\_ngx\_cache\_purge/](http://labs.frickle.com/nginx_ngx_cache_purge/)

GitHub repository is available at:

> **[GitHub - FRiCKLE/ngx\_cache\_purge: nginx module which adds ability to purge...](https://github.com/FRiCKLE/ngx_cache_purge/)**
>
> nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches. - GitHub - FRiCKLE/ngx\_cache\_purge: nginx module which adds ability to purge content from FastCGI, proxy...

Best regards,  
Piotr S. \< removed\_email\_address@domain.invalid \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [June 8, 2010, 5:22am UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/2 "2010-06-08T05:22:03Z")

</div>

Version 1.1 is now available at:  
[http://labs.frickle.com/nginx\_ngx\_cache\_purge/](http://labs.frickle.com/nginx_ngx_cache_purge/)

GitHub repository is available at:

> **[GitHub - FRiCKLE/ngx\_cache\_purge: nginx module which adds ability to purge...](https://github.com/FRiCKLE/ngx_cache_purge/)**
>
> nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches. - GitHub - FRiCKLE/ngx\_cache\_purge: nginx module which adds ability to purge content from FastCGI, proxy...

Changes:  
2010-06-08 VERSION 1.1  
\* Fix compatibility with nginx-0.8.40+.

```
* Add ability to purge content from uWSGI's cache.

```

Best regards,  
Piotr S. \< removed\_email\_address@domain.invalid \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [June 17, 2010, 4:22pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/3 "2010-06-17T16:22:43Z")

</div>

Thanks.

My English is not good and please forgive my bad grammer.

I want only .jpg and .gif be cached, so I wrote:

location ~ .\*.(jpg|gif)$  
{  
proxy\_cache cache1;  
proxy\_cache\_valid 200 304 15m;  
proxy\_cache\_key $host$uri$is\_args$args;  
proxy\_pass [http://backend](http://backend);  
}

location /  
{  
proxy\_pass [http://backend](http://backend);  
}

and here comes a problem: you can’t purge any more, browser show: 404

Can you help me?

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,98939#msg-98939)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [June 17, 2010, 4:27pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/4 "2010-06-17T16:27:01Z")

</div>

Hi,  
You don’t have any purge location, so this can’t work. Please add:

location ~ /purge(/.\*) {  
proxy\_cache\_purge cache1 $host$1$is\_args$args;  
}

_before_ “location ~ .\*.(jpg|gif)$”.

Best regards,  
Piotr S. \< removed\_email\_address@domain.invalid \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [June 17, 2010, 4:27pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/5 "2010-06-17T16:27:01Z")

</div>

And, how can I don’t cache a path-like url ? i.e., [http://www.test.com/](http://www.test.com/)  
or [http://www.test.com/path/](http://www.test.com/path/)

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,98947#msg-98947)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [June 17, 2010, 4:35pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/6 "2010-06-17T16:35:20Z")

</div>

Hi,  
like I said before, you need to put “location ~ /purge(/._)" before  
"location ~ ._.(jpg|gif)$”.

In your current configuration “[http://www.test.com/purge/1.gif](http://www.test.com/purge/1.gif)” is  
served by  
“location ~ .\*.(jpg|gif)$”. This is because both regexp locations match  
your query and in such case nginx picks the first one from the top.

Best regards,  
Piotr S. \< removed\_email\_address@domain.invalid \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [June 17, 2010, 4:35pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/7 "2010-06-17T16:35:20Z")

</div>

THANK YOU VERY MUCH!

What an simple solution it is.

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,99195#msg-99195)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [June 17, 2010, 4:34pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/8 "2010-06-17T16:34:41Z")

</div>

Thank you for your reply.

I mean everything is ok before I limited .jpg and .gif to be cached.  
So I didn’t write all configurations here.  
Then, I give the full version before and current for you to help me.

# Version Ok

# I visited [http://www.test.com/1.gif](http://www.test.com/1.gif),

# and purge it by visiting, [http://www.test.com/purge/1.gif](http://www.test.com/purge/1.gif)

# It’s ok, show: Successful purge …

##########################################################  
server {  
server\_name [www.test.com](http://www.test.com);  
listen 80;

```
    location / {
            proxy_cache cache1;
            proxy_cache_valid 200 304 15m;
            proxy_cache_key $host$uri$is_args$args;
            proxy_pass http://backend;
    }

    location ~ .*\.(php)?$
    {
            proxy_pass http://backend;
    }

    location ~ /purge(/.*)
    {
            proxy_cache_purge cache1 $host$1$is_args$args;
    }
}

```

# Version not ok

# This can’t be purged, show: 404

# and I’m sure I visited [http://www.test.com/1.gif](http://www.test.com/1.gif) again before I

purge.

# It’s in cache indeed, because I can see the picture in my browser

(with F5, and Ctrl+F5) even after I delete 1.gif from that server.  
########################################################  
server {  
server\_name [www.test.com](http://www.test.com);  
listen 80;

```
    access_log logs/proxy.log;

    location ~ .*\.(jpg|gif)$ { # I want only jpg/gif to be cached
            proxy_cache cache1;
            proxy_cache_valid 200 304 15m;
            proxy_cache_key $host$uri$is_args$args;
            proxy_pass http://backend;
    }

    location / # All others not cached
    {
            proxy_pass http://backend;
    }

    location ~ /purge(/.*)
    {
            proxy_cache_purge cache1 $host$1$is_args$args;
    }
}

```

Thank you, I thought you can repeat this problem easily.

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

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [August 11, 2010, 11:59pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/9 "2010-08-11T23:59:54Z")

</div>

Version 1.2 is now available at:  
[http://labs.frickle.com/nginx\_ngx\_cache\_purge/](http://labs.frickle.com/nginx_ngx_cache_purge/)

GitHub repository is available at:

> **[GitHub - FRiCKLE/ngx\_cache\_purge: nginx module which adds ability to purge...](https://github.com/FRiCKLE/ngx_cache_purge/)**
>
> nginx module which adds ability to purge content from FastCGI, proxy, SCGI and uWSGI caches. - GitHub - FRiCKLE/ngx\_cache\_purge: nginx module which adds ability to purge content from FastCGI, proxy...

Changes:  
2010-08-11 VERSION 1.2  
\* Fix various build scenarios with disabled upstream modules.  
Reported by Johan Bergstroem.

```
* Add ability to purge content from SCGI's cache.
  Requested by Johan Bergstroem.

```

Best regards,  
Piotr S. \< removed\_email\_address@domain.invalid \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 12, 2010, 11:45am UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/10 "2010-10-12T11:45:45Z")

</div>

here is my conf:  
fastcgi\_cache\_path /usr/local/nginx/fastcgi\_cache levels=1:2  
keys\_zone=DIGG:10m inactive=2m;

location /  
{  
fastcgi\_cache DIGG;  
fastcgi\_cache\_key $host$uri$is\_args$args;  
fastcgi\_cache\_valid 200 302 1h;  
fastcgi\_cache\_valid 301 1d;  
fastcgi\_cache\_valid any 1m;  
fastcgi\_cache\_min\_uses 2;  
fastcgi\_cache\_use\_stale error timeout invalid\_header http\_500;  
fastcgi\_pass unix:/tmp/php-cgi.sock;  
#fastcgi\_pass 127.0.0.1:9000;  
fastcgi\_index index.php;  
include fcgi.conf;  
}  
location ~ /purge(/.\*)  
{  
allow 127.0.0.1;  
deny all;  
fastcgi\_cache\_purge DIGG $host$1$is\_args$args;  
}  
nginx -t don’t returns any error.  
but when i visit [http://mydomain/purge/xxx.jpg](http://mydomain/purge/xxx.jpg), it returns me a 404  
page.  
i checked the error log and found this:

2010/10/11 05:04:25 [emerg] 8915#0: unknown directive  
“fastcgi\_cache\_purge” in /usr/local/nginx/conf/nginx.conf:27

is there anybody help me? thanks a lot.

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,139639#msg-139639)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 12, 2010, 3:30pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/11 "2010-10-12T15:30:48Z")

</div>

hi Piotr,  
i used nginx 0.75 before, and compile ngx\_cache\_purge with nginx 0.85.2,  
after ./configure --add-module=…/ngx\_cache\_purge-1.2 …(my own  
parameters) and make, i didn’t run a make install and just cp objs/nginx  
covering the old one. it’s general method when i upgrade the nginx. i  
found there is a file named ngx\_cache\_purge\_module.o in the directory  
objs/addon/ngx\_cache\_purge-1.2, but i don’t know where should i cp it  
to. could you please tell me how to install your mod with a running  
nginx?  
thanks a lot  
regards  
solo

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,139710#msg-139710)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 12, 2010, 4:08pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/12 "2010-10-12T16:08:23Z")

</div>

Hi,  
did you restart nginx after that? Reload isn’t sufficient.

Best regards,  
Piotr S. \< removed\_email\_address@domain.invalid \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 12, 2010, 4:47pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/13 "2010-10-12T16:47:11Z")

</div>

hi piotr,  
sure, i have restarted nginx for many times. but it don’t work well now  
still…  
need i copy ngx\_cache\_purge\_module.o to main dir of nginx? or is there  
any way to check whether your mod has been compiled with nginx well?  
regards  
solo

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,139739#msg-139739)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 12, 2010, 2:57pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/14 "2010-10-12T14:57:33Z")

</div>

Hi,

> 2010/10/11 05:04:25 [emerg] 8915#0: unknown directive  
> “fastcgi\_cache\_purge” in /usr/local/nginx/conf/nginx.conf:27

You are _not_ using nginx compiled with ngx\_cache\_purge module.

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 12, 2010, 6:06pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/15 "2010-10-12T18:06:47Z")

</div>

Hi,

> need i copy ngx\_cache\_purge\_module.o to main dir of nginx?

No, this is compile-time object file. You don’t need to worry about it.

> or is there  
> any way to check whether your mod has been compiled with nginx well?

nginx -V

Best regards,  
Piotr S. \< [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 12, 2010, 6:14pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/16 "2010-10-12T18:14:54Z")

</div>

hi piotr,  
i know this line, and it returns me:

nginx version: nginx/0.8.52  
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)  
TLS SNI support disabled  
configure arguments: --user=www --group=www --prefix=/usr/local/nginx  
–with-http\_stub\_status\_module --with-http\_ssl\_module  
–add-module=…/ngx\_cache\_purge-1.2

i think i can’t determine what’s wrong with it still…  
regards  
solo

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,139767#msg-139767)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 13, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/17 "2010-10-13T12:04:30Z")

</div>

hi piotr,  
i’m very sure i’m running the certain nginx, because i’m very puzzled so  
that i delete all old version…  
regards  
solo

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,140028#msg-140028)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 13, 2010, 3:26am UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/18 "2010-10-13T03:26:53Z")

</div>

Hi,  
both of your outputs: “nginx -V” and “nginx -t” suggest that nginx is  
compiled with “fastcgi\_cache\_purge” support.

Are you sure that you’re running the same nginx binary as your init.d  
script? What happens when you execute nginx binary yourself (without  
using  
init.d or other scripts)?

Best regards,  
Piotr S. \< removed\_email\_address@domain.invalid \>

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 13, 2010, 12:51pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/19 "2010-10-13T12:51:29Z")

</div>

hi piotr,  
i have no idea with this case, and have to reinstall whole nginx, it  
works well now, thanks a lot for your help.  
i don’t know why, but it works now…  
regards  
solo

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,140044#msg-140044)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

---

<div class="post-metadata">

**Author:** ![piotrs](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@piotrs](https://www.ruby-forum.com/u/piotrs)\
**Post date:** [October 13, 2010, 1:07pm UTC](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369/20 "2010-10-13T13:07:48Z")

</div>

hi piotr,  
could you please help me one more question? is it useful to cache a php  
script in fastcgi\_cache? in other words, need i disable fastcgi cache  
for all php script? thanks a lot  
regards  
solo

Posted at Nginx Forum:

> **[Re: FRiCKLE Labs & yo.se pres. ngx\_cache\_purge](https://forum.nginx.org/read.php?2,39564,140052#msg-140052)**
>
> Hello, ngx\_cache\_purge is a module which adds ability to purge content from FastCGI and proxy caches. This is rewrite of well-tested cache\_purge patch (kindly funded by yo.se), so hopefully this short introduction is enough ;) You can download it at...

[Next page](https://www.ruby-forum.com/t/frickle-labs-yo-se-pres-ngx-cache-purge/181369.md?page=2)
