Re: Как очистить кэш Nginx

Seriyyy95 nginx-forum на forum.nginx.org
Ср Янв 4 19:19:20 UTC 2017


Конфиг w3 total cache:

# BEGIN W3TC Page Cache cache
location ~ /wp-content/cache/page_enhanced.*html$ {
    expires modified 36000s;
    add_header X-Powered-By "W3 Total Cache/0.9.5.1";
    add_header Vary "Accept-Encoding, Cookie";
    add_header Pragma "public";
    add_header Cache-Control "max-age=36000, public";
}
location ~ /wp-content/cache/page_enhanced.*gzip$ {
    gzip off;
    types {}
    default_type text/html;
    expires modified 36000s;
    add_header X-Powered-By "W3 Total Cache/0.9.5.1";
    add_header Vary "Accept-Encoding, Cookie";
    add_header Pragma "public";
    add_header Cache-Control "max-age=36000, public";
    add_header Content-Encoding gzip;
}
# END W3TC Page Cache cache
# BEGIN W3TC Browser Cache
gzip on;
gzip_types text/css text/x-component application/x-javascript
application/javascript text/javascript text/x-js text/richtext image/svg+xml
text/plain text/xsd text/xsl text/xml image/bmp application/java
application/msword application/vnd.ms-fontobject application/x-msdownload
image/x-icon application/json application/vnd.ms-access
application/vnd.ms-project application/x-font-otf
application/vnd.ms-opentype application/vnd.oasis.opendocument.database
application/vnd.oasis.opendocument.chart
application/vnd.oasis.opendocument.formula
application/vnd.oasis.opendocument.graphics
application/vnd.oasis.opendocument.spreadsheet
application/vnd.oasis.opendocument.text audio/ogg application/pdf
application/vnd.ms-powerpoint application/x-shockwave-flash image/tiff
application/x-font-ttf audio/wav application/vnd.ms-write
application/font-woff application/font-woff2 application/vnd.ms-excel;
location ~ \.(css|htc|less|js|js2|js3|js4)$ {
    expires -1s;
    add_header Pragma "public";
    add_header Cache-Control "max-age=-1, public";
    add_header X-Powered-By "W3 Total Cache/0.9.5.1";
    try_files $uri $uri/ $uri.html /index.php?$args;
}
location ~ \.(html|htm|rtf|rtx|svg|svgz|txt|xsd|xsl|xml)$ {
    expires 36000s;
    add_header Pragma "public";
    add_header Cache-Control "max-age=36000, public";
    add_header X-Powered-By "W3 Total Cache/0.9.5.1";
    try_files $uri $uri/ $uri.html /index.php?$args;
}
location ~
\.(asf|asx|wax|wmv|wmx|avi|bmp|class|divx|doc|docx|eot|exe|gif|gz|gzip|ico|jpg|jpeg|jpe|json|mdb|mid|midi|mov|qt|mp3|m4a|mp4|m4v|mpeg|mpg|mpe|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|png|pot|pps|ppt|pptx|ra|ram|svg|svgz|swf|tar|tif|tiff|ttf|ttc|_ttf|wav|wma|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|zip)$
{
    expires 31536000s;
    add_header Pragma "public";
    add_header Cache-Control "max-age=31536000, public";
    add_header X-Powered-By "W3 Total Cache/0.9.5.1";
    try_files $uri $uri/ $uri.html /index.php?$args;
}
add_header strict-transport-security "max-age=31536000";
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
set $w3tc_rewrite 1;
if ($request_method = POST) {
    set $w3tc_rewrite 0;
}
if ($query_string != "") {
    set $w3tc_rewrite 0;
}
if ($http_cookie ~*
"(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle)")
{
    set $w3tc_rewrite 0;
}
set $w3tc_preview "";
if ($http_cookie ~* "(w3tc_preview)") {
    set $w3tc_preview _preview;
}
set $w3tc_ssl "";
if ($scheme = https) {
    set $w3tc_ssl _ssl;
}
set $w3tc_enc "";
if ($http_accept_encoding ~ gzip) {
    set $w3tc_enc _gzip;
}
if (!-f
"$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_preview.html$w3tc_enc")
{
  set $w3tc_rewrite 0;
}
if ($w3tc_rewrite = 1) {
    rewrite .*
"/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_ssl$w3tc_preview.html$w3tc_enc"
last;
}
# END W3TC Page Cache core

Но кэш w3tc тоже чищен, плюс expires в -1 выставил.

Дальше конфиг самого сайта:

server {
        server_name losst.ru www.losst.ru;
        ssl on;
        ssl_certificate "/var/www/httpd-cert/losst/losst.ru_le2.crtca";
        ssl_certificate_key "/var/www/httpd-cert/losst/losst.ru_le2.key";
        ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH;
        ssl_prefer_server_ciphers on;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        add_header Strict-Transport-Security "max-age=31536000;";
        charset off;
        index index.php;
        disable_symlinks if_not_owner from=$root_path;
        include /etc/nginx/vhosts-includes/*.conf;
        include /etc/nginx/vhosts-resources/losst.ru/*.conf;
        access_log /var/www/httpd-logs/losst.ru.access.log;
        error_log /var/www/httpd-logs/losst.ru.error.log notice;
        ssi off;
        set $root_path /var/www/losst/data/www/losst.ru;
        root $root_path;
        listen 194.67.215.125:443 default_server;

        include /var/www/losst/data/www/losst.ru/nginx.conf;


        location = /nginx.conf {
                deny all;
        }

        location / {

                try_files $uri $uri/ /index.php?$args;

                location ~ [^/]\.ph(p\d*|tml)$ {
                        try_files /does_not_exists @php;
                }

               try_files $uri $uri/ /index.php?$args;

                location ~ [^/]\.ph(p\d*|tml)$ {
                        try_files /does_not_exists @php;
                }
        }
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location @php {
                fastcgi_index index.php;
                fastcgi_param PHP_ADMIN_VALUE "sendmail_path =
/usr/sbin/sendmail -t -i -f admin at losst.ru";
                fastcgi_pass unix:/var/www/php-fpm/losst.sock;
                fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
                try_files $uri =404;
                include fastcgi_params;
        }

}

Насколько я понял nginx выдает статику напрямую, в том и все дело.

Posted at Nginx Forum: https://forum.nginx.org/read.php?21,271820,271825#msg-271825



Подробная информация о списке рассылки nginx-ru