# Proxy\_cache\_purge for nginx/0.8.34

**URL:** <https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758>\
**Category:** NGINX\
**Created:** [March 8, 2010, 7:17am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758 "2010-03-08T07:17:53Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 8, 2010, 7:17am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/1 "2010-03-08T07:17:53Z")

</div>

Can somebody confirm that proxy\_cache\_purge is working with  
nginx/0.8.34.

I have this config and cannot get it to delete anything from the cache,  
I just get a 404:

location / {  
proxy\_pass [http://127.0.0.1:8000](http://127.0.0.1:8000);  
proxy\_cache tmpcache;  
proxy\_cache\_key “$scheme://$host$request\_uri”;  
}

location ~ /purge(/.\*) {  
allow 127.0.0.1;  
deny all;  
proxy\_cache\_purge tmpcache “$scheme://$host$1”;  
}

Thank you.

Posted at Nginx Forum:

> **[proxy\_cache\_purge for nginx/0.8.34](https://forum.nginx.org/read.php?2,61318,61318#msg-61318)**
>
> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34. I have this config and cannot get it to delete anything from the cache, I just get a 404: \[code\] location / { proxy\_pass http://127.0.0.1:8000; proxy\_cache tmpcache;

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 8, 2010, 1:11pm UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/2 "2010-03-08T13:11:25Z")

</div>

> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34.

I just tested it and it works just fine.

Can you confirm that URL that you’re trying to purge is indeed cached?  
Can you post access logs (preferably with $upstream\_cache\_status) for  
the  
cached URL and for failed purges?

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

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 14, 2010, 7:44am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/3 "2010-03-14T07:44:45Z")

</div>

My “purge” URL for the home-page ([http://www.mysite.com/](http://www.mysite.com/)) is  
[http://www.mysite.com/purge/](http://www.mysite.com/purge/)  
I get a 404 and nothing gets purged.

Same thing if I do it for a URL of this form:

[http://www.mysite.com/test-2/2220](http://www.mysite.com/test-2/2220)  
[http://www.mysite.com/purge/test-2/2220](http://www.mysite.com/purge/test-2/2220) won’t do anything, just getting  
a 404.

GET /test-2/2220 upstream\_cache\_status HIT  
GET /purge/test-2/2220 upstream\_cache\_status -

Posted at Nginx Forum:

> **[Re: proxy\_cache\_purge for nginx/0.8.34](https://forum.nginx.org/read.php?2,61318,63633#msg-63633)**
>
> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34. I have this config and cannot get it to delete anything from the cache, I just get a 404: \[code\] location / { proxy\_pass http://127.0.0.1:8000; proxy\_cache tmpcache;

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 14, 2010, 7:52am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/4 "2010-03-14T07:52:57Z")

</div>

It seems that I keep getting upstream\_cache\_status UPDATING  
Does that mean the purging is scheduled somehow?

Posted at Nginx Forum:

> **[Re: proxy\_cache\_purge for nginx/0.8.34](https://forum.nginx.org/read.php?2,61318,63636#msg-63636)**
>
> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34. I have this config and cannot get it to delete anything from the cache, I just get a 404: \[code\] location / { proxy\_pass http://127.0.0.1:8000; proxy\_cache tmpcache;

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 14, 2010, 7:48am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/5 "2010-03-14T07:48:16Z")

</div>

Piotr - is there any way to get proxy\_cache\_purge to log its activity? I  
am not sure it is even working, although I do not get any error message  
when restarting NGINX.

Posted at Nginx Forum:

> **[Re: proxy\_cache\_purge for nginx/0.8.34](https://forum.nginx.org/read.php?2,61318,63634#msg-63634)**
>
> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34. I have this config and cannot get it to delete anything from the cache, I just get a 404: \[code\] location / { proxy\_pass http://127.0.0.1:8000; proxy\_cache tmpcache;

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 14, 2010, 5:19pm UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/6 "2010-03-14T17:19:27Z")

</div>

Hi,

> location ~ /purge(/.\*) {  
> allow 127.0.0.1;  
> deny all;  
> proxy\_cache\_purge tmpcache “$scheme://$host$1”;  
> }

> [http://www.mysite.com/test-2/2220](http://www.mysite.com/test-2/2220)  
> [http://www.mysite.com/purge/test-2/2220](http://www.mysite.com/purge/test-2/2220) won’t do anything, just getting a  
> 404.
> 
> GET /test-2/2220 upstream\_cache\_status HIT  
> GET /purge/test-2/2220 upstream\_cache\_status -

Just to make sure: are you requesting purges from localhost (127.0.0.1)?

> Piotr - is there any way to get proxy\_cache\_purge to log its activity? I  
> am not sure it is even working, although I do not get any error message  
> when restarting NGINX.

At this time it only logs successful purges at http debug level and  
failures  
to delete files from hard disk at critical level.

> It seems that I keep getting upstream\_cache\_status UPDATING  
> Does that mean the purging is scheduled somehow?

No, this has nothing to do with ngx\_cache\_purge.

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

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 14, 2010, 7:04pm UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/7 "2010-03-14T19:04:48Z")

</div>

Hi,

> No, why would I, nginx is listening to external IP.

Why would you? Did you at least look at _your_ configuration?

> allow 127.0.0.1;  
> deny all;

Your request is refused before it even reaches ngx\_cache\_purge module.

> how do I see this log? it will give me a clue into what the  
> proxy\_cache\_purge is doing

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

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

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 14, 2010, 11:58pm UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/8 "2010-03-14T23:58:35Z")

</div>

Here’s the config:

location ~ ^/purge(/.\*)$ {  
allow 127.0.0.1;  
allow 192.168.0.0/16;  
allow 72.12.74.93;  
deny all;  
proxy\_cache\_purge staticfilecache  
“$scheme://$host$1”;  
}

Posted at Nginx Forum:

> **[Re: proxy\_cache\_purge for nginx/0.8.34](https://forum.nginx.org/read.php?2,61318,63815#msg-63815)**
>
> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34. I have this config and cannot get it to delete anything from the cache, I just get a 404: \[code\] location / { proxy\_pass http://127.0.0.1:8000; proxy\_cache tmpcache;

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 15, 2010, 1:59am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/9 "2010-03-15T01:59:45Z")

</div>

Public URL is [http://www.mysite.com/test-2/2220](http://www.mysite.com/test-2/2220)

To request purge I try (on local server): wget  
[www.mysite.com/purge/test-2/2220](http://www.mysite.com/purge/test-2/2220)  
or directly from browser (from one of the IPs in allow):  
[www.mysite.com/purge/test-2/2220](http://www.mysite.com/purge/test-2/2220)

log\_format combinedx '$remote\_addr - $remote\_user [$time\_local] ’  
'“$request” $status $body\_bytes\_sent ’  
'“$http\_referer” “$http\_user\_agent” ’  
'upstream\_response\_time $upstream\_response\_time ’  
'msec $msec request\_time $request\_time ’  
'Expires: $upstream\_http\_expires ’  
'Cache-Control: $upstream\_http\_cache\_control ’  
'upstream\_cache\_status $upstream\_cache\_status ';

access\_log “/var/log/nginx/access.log” combinedx;

Thank you.

Posted at Nginx Forum:

> **[Re: proxy\_cache\_purge for nginx/0.8.34](https://forum.nginx.org/read.php?2,61318,63848#msg-63848)**
>
> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34. I have this config and cannot get it to delete anything from the cache, I just get a 404: \[code\] location / { proxy\_pass http://127.0.0.1:8000; proxy\_cache tmpcache;

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 15, 2010, 12:14am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/10 "2010-03-15T00:14:24Z")

</div>

What IP address are you using to request purge?  
Please show entries from properly formatted access log.

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

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 15, 2010, 2:58am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/11 "2010-03-15T02:58:52Z")

</div>

Entries, not format.

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

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 14, 2010, 6:29pm UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/12 "2010-03-14T18:29:06Z")

</div>

> Just to make sure: are you requesting purges from  
> localhost (127.0.0.1)?

No, why would I, nginx is listening to external IP.

> At this time it only logs successful purges at  
> http debug level and failures  
> to delete files from hard disk at critical level.

how do I see this log? it will give me a clue into what the  
proxy\_cache\_purge is doing

> > It seems that I keep getting  
> > upstream\_cache\_status UPDATING  
> > Does that mean the purging is scheduled somehow?
> 
> No, this has nothing to do with ngx\_cache\_purge.

correct.

Thank you.

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

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 15, 2010, 5:57am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/13 "2010-03-15T05:57:54Z")

</div>

> 74.65.58.194 - - [15/Mar/2010:00:35:29 -0400] “GET /purge/ HTTP/1.0” 404  
> ^^^^^^^^^^^^  
> this IP isn’t on your allowed list:

> allow 127.0.0.1;  
> allow 192.168.0.0/16;  
> allow 72.12.74.93;

> Question: what am I supposed to see/get after a successful purge?

[![](http://zyan.cc/attachment/201001/nginx_purge.png) ](http://zyan.cc/attachment/201001/nginx_purge.png)

> Thanks for all your help Piotr but I don’t want to waste your time  
> indefinitely.  
> All I need is to see the activity log for proxy\_cache\_purge, and we can go  
> from there.

All you need to do is use proper access list. There is no activity when  
your  
request is blocked in the access phase.

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

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 15, 2010, 5:38am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/14 "2010-03-15T05:38:36Z")

</div>

74.65.58.194 - - [15/Mar/2010:00:35:29 -0400] “GET /purge/ HTTP/1.0”  
404 1656 “-” “Wget/1.11.4 Red Hat modified” upstream\_response\_time -  
msec 1268627729.628 request\_time 0.000 Expires: - Cache-Control: -  
upstream\_cache\_status -

Question: what am I supposed to see/get after a successful purge?

Thanks for all your help Piotr but I don’t want to waste your time  
indefinitely.  
All I need is to see the activity log for proxy\_cache\_purge, and we can  
go from there.

Thank you.

Posted at Nginx Forum:

> **[Re: proxy\_cache\_purge for nginx/0.8.34](https://forum.nginx.org/read.php?2,61318,63894#msg-63894)**
>
> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34. I have this config and cannot get it to delete anything from the cache, I just get a 404: \[code\] location / { proxy\_pass http://127.0.0.1:8000; proxy\_cache tmpcache;

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 15, 2010, 5:03pm UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/15 "2010-03-15T17:03:59Z")

</div>

> That is a dummy IP.

I cannot investigate your problem when you’re giving me false data.

> I believe that, if cache file doesn’t exist response is still 404.

Yes, it is.

> Wouldn’t be helpful to return a message “cache file does not exists”  
> instead of a 404.

No, 404 is standard HTTP response code for “File Not Found” and it is  
exactly the response that any sane person would expect when “cached  
file”  
does not exist. There is no way that this is gonna change.

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

---

<div class="post-metadata">

**Author:** ![skynet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/919ad9/32.png) [@skynet](https://www.ruby-forum.com/u/skynet)\
**Post date:** [March 15, 2010, 6:45am UTC](https://www.ruby-forum.com/t/proxy-cache-purge-for-nginx-0-8-34/184758/16 "2010-03-15T06:45:53Z")

</div>

That is a dummy IP.

Now, seeing is believing – I gave it another try and it actually gave  
me the response similar to the screenshot.  
Not sure why but it is very sporadic. I believe that, if cache file  
doesn’t exist response is still 404.  
Of course, the cache file exists, therefore question is - why so  
sporadic.  
Wouldn’t be helpful to return a message “cache file does not exists”  
instead of a 404.

Thanks again.

Posted at Nginx Forum:

> **[Re: proxy\_cache\_purge for nginx/0.8.34](https://forum.nginx.org/read.php?2,61318,63901#msg-63901)**
>
> Can somebody confirm that proxy\_cache\_purge is working with nginx/0.8.34. I have this config and cannot get it to delete anything from the cache, I just get a 404: \[code\] location / { proxy\_pass http://127.0.0.1:8000; proxy\_cache tmpcache;
