nginx如何对静态资源进行gzip压缩


通过Nginx访问的静态文件下载到浏览器客户端超过10秒,这时候要注意是否进行了gzip压缩,看响应头response header

 

 

具体设置如下:

server {
       listen      80;
       server_name  abc.baidu.com;
       root   /etc/nginx/html/h5;
       index  index.html;
       gzip on;
       gzip_buffers 32 4K;
       gzip_comp_level 6;
       gzip_min_length 100;
       gzip_types application/javascript text/css text/xml;
       gzip_disable "MSIE [1-6]\.";
    location ~ ^/MP_verify.*\.txt$  {
        root   /data/h5/;
        index index.html;
    }
        location / {
                try_files $uri $uri/ @router;
                index index.html;
        }
        location @router {
                rewrite ^.*$ /index.html last;
        }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM