Skip to content

Instantly share code, notes, and snippets.

@patrickmaciel
Created April 7, 2016 20:10
Show Gist options
  • Save patrickmaciel/7930b653e2b01eea56b14bdcb6d39fc9 to your computer and use it in GitHub Desktop.
Save patrickmaciel/7930b653e2b01eea56b14bdcb6d39fc9 to your computer and use it in GitHub Desktop.
Configuração do Nginx para um site Wordpress - utilizando um cache violento
# fastcgi_cache_path /var/run/nginx-cache levels=1:2 keys_zone=WORDPRESS:25m inactive=1440m;
# fastcgi_cache_key "$scheme$request_method$host$request_uri";
# fastcgi_cache_use_stale error timeout invalid_header http_500;
# fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
server {
listen 80;
root /var/www/html/pasta_do_wordpress;
index index.php index.html index.htm;
server_name dominiodosite.com.br;
charset UTF-8;
set $skip_cache 0;
if ($request_method = POST) {
# set $skip_cache 1;
}
if ($query_string != "") {
# set $skip_cache 1;
}
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|/wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
# set $skip_cache 1;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
# fastcgi_cache_bypass $skip_cache;
# fastcgi_no_cache $skip_cache;
# fastcgi_cache WORDPRESS;
# fastcgi_cache_valid 1440m;
}
# location ~ /purge(/.*) {
# fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
# }
# location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
location ~* \.(js|css|png|jpg|jpeg|gif|ico|eot|otf|ttf|woff)$ {
add_header Access-Control-Allow-Origin *;
access_log off;
log_not_found off;
expires 30d;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment