我
編輯1
不進行壓縮application/javascript,但comresses text/htmlwhilletext/html沒有列gzip_types:

實際上向gzip on;配置添加/remoing指令沒有效果。
更改為
您也可以嘗試對靜態 URL 進行測驗,Nginx 將Content-Encoding: gzip在正確配置后回傳:
location ~ ^/test.js$ {
gzip_types application/javascript;
gzip on;
default_type application/javascript;
return 200 "/***** hello *****/";
}
$ curl --compressed -kIX GET https://example.com/test.js
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 01 Dec 2021 00:00:00 GMT
Content-Type: application/javascript; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip
uj5u.com熱心網友回復:
它不是 Nginx,它是 Google Chrome 瀏覽器,按 F5 實際上不會重新加載 javascript(如果未選中禁用快取)。
在您的/etc/nginx/nginx.conf:
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml rss text/javascript;
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/376071.html
上一篇:如何重定向NGINX
