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