Opened 8 years ago

Closed 8 years ago

#1204 closed defect (duplicate)

"gzip_vary" will add a duplicate Vary header if a PHP page also adds a Vary header

Reported by: RichardBradley@… Owned by:
Priority: major Milestone:
Component: nginx-core Version: 1.10.x
Keywords: gzip, gzip_vary Cc:
uname -a: Linux ip-10-56-38-16.eu-west-1.compute.internal 2.6.32-642.13.1.el6.x86_64 #1 SMP Wed Jan 11 20:56:24 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.10.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-mail=dynamic --with-mail_ssl_module --with-pcre --with-pcre-jit --with-stream=dynamic --with-stream_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=' -Wl,-E'

Description

I have a PHP app served by nginx, and I'd like to enable gzip output compression.

I have turned on the "gzip" and "gzip_vary" settings:

/etc/nginx/nginx.conf:    gzip  on;
/etc/nginx/nginx.conf:    gzip_vary on;
/etc/nginx/nginx.conf:    gzip_disable "msie6";

My PHP app already adds a Vary header.

Observed Behaviour

Unfortunately this causes nginx to add a duplicate Vary header:

HTTP/1.1 200 OK
Server: nginx
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Cache-Control: max-age=300, public
Vary: Accept-Encoding,X-Cookie-ckps_language
Content-language: en-GB
Date: Mon, 13 Feb 2017 15:20:39 GMT

Expected Behaviour

I believe that nginx should merge the "Vary" header added by gzip_vary with any Vary headers produced by hosted apps.

Previous reports of this bug

See also:

Change History (2)

comment:1 by RichardBradley@…, 8 years ago

Actually, as Jason Martin has just explained to me on "serverfault", multiple "Vary" headers are allowed by the HTTP specs and have the same effect as a single comma separated Vary header.

http://serverfault.com/a/832295/140833

So there's no bug here, just some possibly surprising behaviour that I didn't understand, sorry.

comment:2 by Maxim Dounin, 8 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #875.

Note: See TracTickets for help on using tickets.