gzip doesn't work while backend response include a Accept-Ranges header

foxgab nginx-forum at forum.nginx.org
Wed Jun 20 09:48:24 UTC 2018


i configured gzip like bellow:
http {
    gzip            on;
    gzip_comp_level 5;
    gzip_http_version 1.0;
    gzip_proxied    any;
    gzip_min_length 1k;
    gzip_types      text/css text/plain text/javascript text/xml
application/json application/javascript application/x-javascript;
    ...
    upstream proxy_static_srv {
        ...
    }
    server {
        ...
        location /static {
            proxy_pass http://proxy_static_srv
        }
    }
}
-----------------------------------------------
i found some .js file didn't compressed if a Accept-Ranges header appeared
in the response, others doing well. what's wrong?
request:
    Host: i.xxxxx.com
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:52.0)
Gecko/20100101 Firefox/52.0
    Accept: */*
    Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3
    Accept-Encoding: gzip, deflate, br
    Cookie: _ga=GA1.2.313391719.1521699529; 
    Connection: keep-alive
    Pragma: no-cache
    Cache-Control: no-cache
response:
    Accept-Ranges: bytes
    Cache-Control: max-age=28800
    Connection: keep-alive
    Content-Length: 1481234
    Content-Type: application/javascript; charset=utf-8
    Date: Wed, 20 Jun 2018 08:56:08 GMT
    Etag: "5b23c8c3-169a12"
    Expires: Wed, 20 Jun 2018 16:56:08 GMT
    Keep-Alive: timeout=60
    Last-Modified: Fri, 15 Jun 2018 14:10:11 GMT
    Server: nginx
the static servers are nginx too, why sometimes this header appeared in the
response?

--------------------------------------------------
[root at nginx-prd3-public-huiju-a1]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.10.3
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) 
built with OpenSSL 1.0.2h  3 May 2016
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx
--with-http_stub_status_module --with-http_v2_module --with-http_ssl_module
--with-ipv6 --with-http_gzip_static_module --with-http_realip_module
--with-http_flv_module --with-openssl=/usr/local/src/openssl-1.0.2h/
--with-pcre=/usr/local/src/pcre-8.39/ --with-pcre-jit
--with-ld-opt=-ljemalloc --with-ld-opt=-Wl,-rpath,/usr/local/luajit/lib
--add-module=/usr/local/src/ngx_devel_kit-0.2.19
--add-module=/usr/local/src/lua-nginx-module-0.10.2
--add-module=/usr/local/src/nginx-sticky-module-1.1-master
--add-module=/usr/local/src/nginx_upstream_check_module-master
--add-dynamic-module=/usr/local/src/headers-more-nginx-module-master/
--with-stream --with-http_realip_module --with-file-aio

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,280186,280186#msg-280186



More information about the nginx mailing list