Curl can response gzip but browser can't

my environment is nginx(1.3.11) + php-fpm

curl -I -H “Accept-Encoding: gzip,deflate”

HTTP/1.1 200 OK
Server: nginx
Date: Fri, 18 Jan 2013 05:18:31 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Vary: Accept-Encoding
Set-Cookie: PHPSESSID=2quqa651uglt62ku49re2nt1n4; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
Pragma: no-cache
Content-Encoding: gzip

but when use browser like chrome and it’s response not contain
Content-Encoding, what’s wrong?

my nginx setting is

gzip on;
gzip_buffers 4 16k;
gzip_comp_level 3;
gzip_http_version 1.1;
gzip_min_length 1k;
gzip_proxied any;
gzip_types text/plain text/css application/json 

text/xml application/xml application/xml+rss text/javascript;
gzip_vary on;
gzip_disable msie6;


Posted at Nginx Forum:


On Fri, Jan 18, 2013 at 06:11:06AM -0500, wingoo wrote:

Set-Cookie: PHPSESSID=2quqa651uglt62ku49re2nt1n4; path=/


It looks like something on your host interferes with normal
request handling. Probably some firewall with content
inspection and/or antivirus software.

I was able to simplify test case down to the LF vs CRLF difference
in the following requests:

$ (printf “GET / HTTP/1.1\r\nHost:\r\nAccept-Encoding:
gzip\r\n\r\n”; sleep 1) | nc 80 | grep Content-Encoding
$ (printf “GET / HTTP/1.1\nHost:\nAccept-Encoding:
gzip\n\n”; sleep 1) | nc 80 | grep -a Content-Encoding
Content-Encoding: gzip

No gzip is returned with proper CRLF newlines, while with just
bare LFs gzip is returned (likely because it bypasses content
inspection in question).

Try disabling your antivirus software to see if it helps.

Maxim D.