server {
server_name example.com
www.example.com; root /var/www/;
listen 80;
index index.html index.htm index.php;
include conf.d/drop;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~* \.(css|js) {
if (!-f $request_filename) {
rewrite ^/wp-content/w3tc/min/(.+\.(css|js))$ /wp-content/w3tc/min/index.php?file=$1 last;
}
}
set $cache_uri $request_uri;
if ($request_method = POST) {
set $cache_uri 'no cache';
set $do_not_cache 1;
}
if ($query_string != "") {
set $cache_uri 'no cache';
set $do_not_cache 1;
}
if ($request_uri ~* "(\/wp-admin\/|\/xmlrpc.php|\/wp-(app|cron|login|register|mail)\.php|wp-.*\.php|index\.php|wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php)") {
set $cache_uri "no cache";
set $do_not_cache 1;
}
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp\-postpass|wordpress_logged_in") {
set $cache_uri 'no cache';
set $do_not_cache 1;
}
location ~* \.(xml|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
try_files $uri =404;
access_log off;
expires 7d;
}
location ~ \.php$ {
fastcgi_buffers 8 256k;
fastcgi_buffer_size 128k;
fastcgi_intercept_errors on;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/dev/shm/php-fpm-www.sock;
}
}