FRiCKLE Labs & yo.se pres. ngx_cache_purge

Hi,

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

This depends on your scripts, it’s up to you to decide whatever their
results are cacheable or not.

Best regards,
Piotr S. < [email protected] >

Caching php opcode reduces processing time for non fastcgi_cached Pages

Sent from my iPod

Version 1.3 is now available at:
http://labs.frickle.com/nginx_ngx_cache_purge/

GitHub repository is available at:

Changes:
2011-05-03 VERSION 1.3
* Fix compatibility with nginx-1.0.1.
Reported by Sergey A. Osokin and Markus Linnala.

2010-08-29
* Fix compatibility with nginx-0.8.0 and versions older than
nginx-0.7.60.

Best regards,
Piotr S. < [email protected] >

I need some help on “FASTCGI(PHP) CACHE PURGE”.

I successfully configured my nginx to support purge fastcgi cache with
Ctrl+F5,while I found that I can not purge the cache by request a uri
like below:

http://myserver.com/purge/test.php
OR
http://myserver.com/purge/myserver.com/test.php

It always returns a 404 error :frowning:

HOW CAN I DO IT? Please help me~

Here is the key part of my nginx.conf:


http {
include mime.types;
default_type application/octet-stream;

fastcgi_cache_path /tmp/fastcgi_cache levels=1:2 keys_zone=TEST:10m
inactive=5m;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 16k;
fastcgi_buffers 16 16k;
fastcgi_busy_buffers_size 16k;
fastcgi_temp_file_write_size 16k;
fastcgi_cache TEST;
fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1d;
fastcgi_cache_valid any 1m;
fastcgi_cache_min_uses 1;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_cache_key $host$uri$is_args$args;

 ...

server {
listen 80;
server_name myserver.com;
root /home/wwwroot;
index index.html index.htm index.php;

if ($request_method = 'PURGE') {
  rewrite ^(.*)$ /purge$1 last;
}

if ($http_cache_control ~ "no-cache") {
  set $http_cache_control 'max-age=604800';
  rewrite ^(.*)$ /purge$1 last;
}

location ~ /purge(/.*) {
  #allow 127.0.0.1;
  #deny all;
                fastcgi_cache_purge TEST $host$1$is_args$args;
}

location ~ .*\.(php|php5)?$ {
  fastcgi_pass unix:/tmp/php-cgi.sock;
  fastcgi_index index.php;
  fastcgi_split_path_info ^(.+\.php)(.*)$;
  include fcgi.conf;
}

                            ...

log_format access '$remote_addr - $remote_user [$time_local]

“$request” ’
'$status $body_bytes_sent “$http_referer” ’
‘“$http_user_agent”
$http_x_forwarded_for’;
access_log /home/wwwlogs/access.log access;
}

}

Hi,
assuming that you didn’t change order of locations during copy & paste
(which is important) then accessing
http://myserver.com/purge/test.php
should purge content which is normally available under
http://myserver.com/test.php”.

If that’s not the case, then please try debugging it
(A debugging log) with ngx_cache_purge-1.4
(just
released) and look for cache-related entries.

Best regards,
Piotr S. < [email protected] >

This is an interesting feature, would be awsome if this got included in
the
core. Can it be made to work based of DELETE (method) requests I wonder?

Wow~ All things go right after I installed the ngx_cache_purge-1.4 !
Thanks very much!

Posted at Nginx Forum: