Forum: NGINX proxy_cache_purge for nginx/0.8.34

Posted by skynet (Guest)
on 2010-03-08 07:17
(Received via mailing list)
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;
  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: 
http://forum.nginx.org/read.php?2,61318,61318#msg-61318
Posted by Piotr Sikora (Guest)
on 2010-03-08 13:11
(Received via mailing list)
> 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 Sikora < piotr.sikora@frickle.com >
Posted by skynet (Guest)
on 2010-03-14 07:44
(Received via mailing list)
My "purge" URL for the home-page (http://www.mysite.com/) is 
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/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: 
http://forum.nginx.org/read.php?2,61318,63633#msg-63633
Posted by skynet (Guest)
on 2010-03-14 07:48
(Received via mailing list)
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: 
http://forum.nginx.org/read.php?2,61318,63634#msg-63634
Posted by skynet (Guest)
on 2010-03-14 07:52
(Received via mailing list)
It seems that I keep getting upstream_cache_status UPDATING
Does that mean the purging is scheduled somehow?

Posted at Nginx Forum: 
http://forum.nginx.org/read.php?2,61318,63636#msg-63636
Posted by Piotr Sikora (Guest)
on 2010-03-14 17:19
(Received via mailing list)
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/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 Sikora < piotr.sikora@frickle.com >
Posted by skynet (Guest)
on 2010-03-14 18:29
(Received via mailing list)
> 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
Posted by Piotr Sikora (Guest)
on 2010-03-14 19:04
(Received via mailing list)
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

http://wiki.nginx.org/NginxCoreModule#error_log

Best regards,
Piotr Sikora < piotr.sikora@frickle.com >
Posted by skynet (Guest)
on 2010-03-14 23:58
(Received via mailing list)
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: 
http://forum.nginx.org/read.php?2,61318,63815#msg-63815
Posted by Piotr Sikora (Guest)
on 2010-03-15 00:14
(Received via mailing list)
What IP address are you using to request purge?
Please show entries from properly formatted access log.

Best regards,
Piotr Sikora < piotr.sikora@frickle.com >
Posted by skynet (Guest)
on 2010-03-15 01:59
(Received via mailing list)
Public URL is http://www.mysite.com/test-2/2220

To request purge I try (on local server): wget 
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

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: 
http://forum.nginx.org/read.php?2,61318,63848#msg-63848
Posted by Piotr Sikora (Guest)
on 2010-03-15 02:58
(Received via mailing list)
Entries, not format.

Best regards,
Piotr Sikora < piotr.sikora@frickle.com >
Posted by skynet (Guest)
on 2010-03-15 05:38
(Received via mailing list)
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: 
http://forum.nginx.org/read.php?2,61318,63894#msg-63894
Posted by Piotr Sikora (Guest)
on 2010-03-15 05:57
(Received via mailing list)
> 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://blog.s135.com/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 Sikora < piotr.sikora@frickle.com >
Posted by skynet (Guest)
on 2010-03-15 06:45
(Received via mailing list)
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: 
http://forum.nginx.org/read.php?2,61318,63901#msg-63901
Posted by Piotr Sikora (Guest)
on 2010-03-15 17:03
(Received via mailing list)
> 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 Sikora < piotr.sikora@frickle.com >
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.