Plesk + NGiNX guía de optimización
Últimamente he tenido que estar tocando mucho configuraciones de PLESK + NGiNX para clientes y he decidido plasmar aquí algunas de las averiguaciones que he completado.
Activar CACHE y Compresión GZIP.
# GZIP
gzip on;
gzip_disable "MSIE [1-6]\\.(?!.*SV1)";
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_proxied any;
gzip_comp_level 9;
gzip_types text/plain text/css application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml;
gzip_vary on;
# NGINX Cache
location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff)$ {
expires 30d;
add_header Cache-Control "public";
log_not_found off;
}
location ~* \.(jpg|jpeg|gif|png)$ {
expires 365d;
log_not_found off;
}
location ~* \.(pdf|css|html|js|swf)$ {
expires 2d;
log_not_found off;
}
location ~ \.css {
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
Si tu sitio usa WordPress te recomiendo añadir esto:
# WORDPRESS PERMALINKS
if (!-e $request_filename) {
rewrite ^(.+)$ /index.php?q=$1 last;
}
# PROTECCION DE CONFIG Y CONTENT
location ~* wp-config.php { deny all; }
location ~* "^/wp-content/(?!plugins/).*\.php" { deny all; }
#WP SUPER CACHE
set $cache_uri $request_uri;
# NO CACHEAR POST Y URLS CON QUERY STRINGS
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
# NO CACHEAR LAS SIGUIENTES URIS
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
# NO CACHEAR A LOS USUARIOS CON SESION INICIADA
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
# USAR CACHE SI EXISTE, SI NO, USAR WORDPRESS
location ~ / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;
}
Deja una respuesta