我们在/ etc / nginx / site-available / default中添加了expire标头,但未反映在gtmatrix / google速度中,我们还检查了curl网站。
请检查下面的代码,
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";
}
}
谢谢!
答案 0 :(得分: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 。
最诚挚的问候,