如何添加在nginx的到期头?

问题描述 投票:0回答:1

我们已经添加了过期头在/ etc / nginx的/网站/可默认,但在gtmatrix /谷歌的速度不反映,我们也请与卷曲的网站。

请在下面检查我们的代码,

server {

root /var/www/html;

location / {

index index.php index.html;
try_files $uri $uri/ @handler;
}
location /. {
    return 404;
}

location @handler {
    rewrite / /index.php;
}

location ~ .php/ {
    rewrite ^(.*.php)/ $1 last;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {

if (!-e $request_filename) {
            rewrite / /index.php last;
            }

include snippets/fastcgi-php.conf;
# With php7.0-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
        fastcgi_read_timeout 20000;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        #fastcgi_param PHP_VALUE "memory_limit = -1";
}

    location ~* .(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg)$ {
        expires 30d;
        add_header Pragma "public";
        add_header Cache-Control "public";
        }    
}

提前致谢!

nginx magento-1.9 google-pagespeed expires-header
1个回答
0
投票

你可以用反斜线试试?

location ~* \.(js|jpg|jpeg|gif|png|css|tgz|gz|rar|bz2|doc|pdf|ppt|tar|wav|bmp|rtf|swf|ico|flv|txt|woff|woff2|svg)$ {
    expires 30d;
    add_header Pragma "public";
    add_header Cache-Control "public";
} 

此外,您可能希望将块以用gzip关闭时,它是有道理的分裂。

最好的祝福,

© www.soinside.com 2019 - 2024. All rights reserved.