我不确定为什么gzip在网页测试和gtmetrix上显示为失败,因为在我的nginx配置中启用了它。
我目前正在运行nginx version: nginx/1.10.1
这是我目前的nginx配置
# HTTPS
server {
listen 443 ssl http2 default_server;
root /home/www/youtstream;
server_name dev.yout.com
gzip_disable "msie6";
access_log off;
error_log off;
gzip_vary on;
gzip on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon;
ssl on;
ssl_certificate /srv/dehydrated/certs/dev.yout.com/fullchain.pem;
ssl_certificate_key /srv/dehydrated/certs/dev.yout.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static {
alias /home/www/youtstream/static/;
}
location ~* \.(jpg|jpeg|png|gif|ico|css|js|mp4|woff2)$ {
expires max;
}
的结果