nginx gzip safari 不起作用,但 chrom 工作成功

nginx gzip safari 不起作用,但 chrom 工作成功

第一个 nginx 配置:

gzip on;
gzip_comp_level    9;
gzip_min_length    256;
gzip_disable "msie6";
gzip_buffers 32 4k;
gzip_http_version 1.1;
gzip_static on;
gzip_proxied       any;
gzip_vary          on;
gzip_types
    application/atom+xml
    # 这个application/x-javascript还是有区别的
    application/javascript
    application/json
    application/ld+json
    application/manifest+json
    application/rss+xml
    application/vnd.geo+json
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    application/xml

chrom测试gzip是否成功,网络包如下:

  • 要求
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cache-Control: no-cache
Connection: keep-alive
Cookie: XSRF-TOKEN=eyJpdiI6ImNrWW5LSzNMVmdNb2VrZDNMZFJUdWc9PSIsInZhbHVlIjoib1hqM0NjUXAzQnZhY0Q0eWVqb1ZaMWxQRDFXT25vVGJ4VHNcL3Rvd05qR3JXdXR5OGIzdzFkM1d0OHEySHVDcFwvIiwibWFjIjoiNjU4ZWNlZjBjZDBhY2EzNWU3YzBmYjEzZThlZTU2ZDk2OGM4OGI3Y2JlYTA1ZmQyYTdhNGZjYWJlNTgwMzBkMiJ9; laravel_session=eyJpdiI6InEyTk5LRHhiWmo5K3U2QmduM3dqc0E9PSIsInZhbHVlIjoiKzJYQnpUXC9LTHVVRXdDRXB3eUx5SWpkMlVwQTEwVDRGbEVmcDNYcENhUjd2OUQxZXhiZ3ZWNlk4OUhsc05sQXAiLCJtYWMiOiJlMjc2NmE4ZjE4MTZlNmI3YTkyYzRhMTdmMjBlNTBiODZmYzkxN2QwMmFjODVmZjhjOGI0ZjI5YmRkZDExMTEwIn0%3D
Host: local.admin.datacenter.com:15000
Pragma: no-cache
Referer: http://local.admin.datacenter.com:15000/index
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36
  • 回复
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/javascript
Date: Sat, 12 Dec 2020 15:57:50 GMT
ETag: W/"5f2da256-178aca"
Last-Modified: Fri, 07 Aug 2020 18:49:58 GMT
Server: Tengine/2.3.2
Transfer-Encoding: chunked
Vary: Accept-Encoding

Safari测试gzip出错,网络包如下:

  • 要求
GET /js/echarts.all.js HTTP/1.1
Cookie: XSRF-TOKEN=eyJpdiI6IjN6K2tyd05GaWpPWStETThONmhac3c9PSIsInZhbHVlIjoiakNSYUNFUklVSEZIZGxEdEpCOGRGa0NHb2lvVGh0Ulc5XC82RzBXTnJod2J0c3o2U1dFSkgya3lXalwvaFNZb0VUIiwibWFjIjoiY2QwMDZkMTBmN2ZkNWY5Mjk1YWUxMDQ5N2NmMjVlODYwZDI4ZDc5NTc3YTc5ZDBjYjlhNzhlNjMzODE4MzY0ZCJ9; laravel_session=eyJpdiI6Im5MMDdab2pHclZNc1wvSkpKSnVPK3dRPT0iLCJ2YWx1ZSI6IjdibmM4dUcxS3VRaUJuSjR5REUwMzk5Y2NcLzByUUxaejB6Q1VMSlptcUtEWVQxalZPcURUampqUlk0T2RkdFE1IiwibWFjIjoiYjRiNjJhOGE4ZTIwZThjYWFhODZmZTYzNWQzMmNiMDY3NmRhODBlYjYwZDE4NWNiNzYwNGNjZGNlYTY0NDA0NyJ9
Accept: */*
Pragma: no-cache
Referer: http://local.admin.datacenter.com:15000/index
Cache-Control: no-cache
Host: local.admin.datacenter.com:15000
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
Connection: keep-alive
  • 回复
HTTP/1.1 200 OK
Connection: keep-alive
Content-Type: application/javascript
Last-Modified: Fri, 07 Aug 2020 18:49:58 GMT
Vary: Accept-Encoding
Transfer-Encoding: Identity
Date: Sat, 12 Dec 2020 16:08:25 GMT
Content-Encoding: gzip
ETag: W/"5f2da256-178aca"
Server: Tengine/2.3.2

请各位大神帮忙解答一下,为什么 chrom gizp 可以成功,但是 safari 却不行?而且 safari 的响应内容是 Content-Encoding: gipz,为什么文件大小没有变化?谢谢大家

相关内容