Plain and simple, without any rewrite rules, supports caching of GET request with memcache. Can it be done simpler than this? This was written and tested with Zend Framework environment, but can be used with any application that have single point of entry.
server {
# How we access the site
listen 80;
server_name $HOSTNAME;
# Where the site resides
root $WEBROOT;
charset utf-8;
# Max post/upload size
client_max_body_size 8m;
fastcgi_param SCRIPT_FILENAME $document_root/boot/index.php;
include /usr/local/nginx/conf/fastcgi_params;
# Deny access to .ht* files
location ~ /\.(ht|svn) {
deny all;
}
location ~ (favicon.ico|robots.txt) {
expires 7d;
log_not_found off;
break;
}
location ~ ^/(gui|opt.js)/ {
expires 7d;
break;
}
location / {
log_not_found off;
default_type text/html;
proxy_intercept_errors on;
recursive_error_pages on;
if ($request_method = 'GET') {
set $memcached_key "output-cache:$uri$is_args$args";
memcached_pass localhost:31307;
error_page 404 502 504 = @php;
break;
}
fastcgi_pass unix:/tmp/php-fpm.sock;
}
location @php {
fastcgi_pass unix:/tmp/php-fpm.sock;
}
}