enabling SPDY (patch 42) +nginx 1.3.2 breaks gzip

Valentin V. Bartenev ne at vbart.ru
Tue Jun 26 19:23:39 UTC 2012


On Tuesday 26 June 2012 22:43:11 pgndev wrote:
> building nginx 1.3.2 + SPDY patch
> (http://nginx.org/patches/spdy/patch.spdy-42.txt)
> 
> with SPDY disabled, response headers show backend's gzip compression
> headers
> 
> (1) nginx/1.3.2, SPDY <- OFF + Varnish3
> 
> 	nginx vhost conf:
> 		listen      192.168.1.17:443;
> 		listen      [2001:453:3cd6:7b2::9]:443 ipv6only=on;
> 
> 	Response Headers
> 		Accept-Ranges	bytes
> 		Age	5
> 		Cache-Control	public, max-age=300
> ==>		Content-Encoding	gzip
> 		Content-Language	en
> 		Content-Length	4560
> 		Content-Type	text/html; charset=utf-8
> 		Date	Tue, 26 Jun 2012 16:55:27 GMT
> 		Expires	Sun, 19 Nov 1978 05:00:00 GMT
> 		Last-Modified	Tue, 26 Jun 2012 16:55:18 GMT
> 		Link	<https://test.svr06.loc/>; rel="canonical"
> ==>		Server	nginx
> 		Vary	Accept-Encoding,User-Agent
> 		Via	1.1 varnish
> 		X-Cache-Hits	1
> 		X-Drupal-Cache	MISS
> 		X-Varnish	179527312 179527285
> 		X-Varnish-Cache	HIT
> 		x-ua-compatible	IE=Edge,chrome=1
> 
> 
> 	Request Headers
> 		Accept	
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> ==>		Accept-Encoding	gzip, deflate
> 		Accept-Language	en,en-us;q=0.5
> 		Connection	keep-alive
> 		Cookie	has_js=1
> 		DNT	1
> 		Host test.svr06.loc
> 		User-Agent	Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20100101
> Firefox/13.0.1
> 
> 
> 
> 
> 
> with SPDY EN-abled, gzip response headers are missing
> 
> 
> (2) nginx/1.3.2, SPDY <- ON + Varnish3
> {{{
> 	nginx vhost conf:
> 		listen      192.168.1.17:443 ssl spdy;
> 		listen      [2001:453:3cd6:7b2::9]:443 ssl spdy ipv6only=on;
> 
> 	Response Headers
> 		Age	26
> 		Cache-Control	public, max-age=300
> 		Content-Language	en
> 		Content-Type	text/html; charset=utf-8
> 		Date	Tue, 26 Jun 2012 16:51:22 GMT
> 		Expires	Sun, 19 Nov 1978 05:00:00 GMT
> 		Last-Modified	Tue, 26 Jun 2012 16:50:52 GMT
> 		Link	<https://test.svr06.loc/>; rel="canonical"
> ==>		Server	nginx
> 		Vary	Accept-Encoding,User-Agent
> 		Via	1.1 varnish
> 		X-Cache-Hits	1
> 		X-Drupal-Cache	MISS
> ==>		X-Firefox-Spdy	1
> 		X-Varnish	851454988 851454961
> 		X-Varnish-Cache	HIT
> 		x-ua-compatible	IE=Edge,chrome=1
> 
> 	Request Headers
> 		Accept	
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> ==>		Accept-Encoding	gzip, deflate
> 		Accept-Language	en,en-us;q=0.5
> 		Connection	keep-alive
> 		Cookie	has_js=1
> 		DNT	1
> 		Host test.svr06.loc
> 		User-Agent	Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20100101
> Firefox/13.0.1
> 

Actually, Firefox doesn't* send the "Accept-Encoding" header over SPDY 
connection, and Nginx doesn't add it when proxying to backend.

* Note, that Firebug isn't accurate about the headers have actually been sent.

The issue is clear enough and will be fixed in the future revision. Currently, 
you can use something like this:

    map $spdy $spdy_ae {
        default  $http_accept_encoding;
        2        "gzip, deflate";
    }

    proxy_set_header Accept-Encoding $spdy_ae;

or enable compression in Nginx.

 wbr, Valentin V. Bartenev



More information about the nginx-devel mailing list