Gzip issues [bug?] Content-type has charset set


#1

I have 2 sites set up, one gzips the js and css as requested with no
issues and the other does not. I spent some time scratching my head on
this one till I noticed the following

The site that does not compress when requested has:

Content-Type: application/x-javascript; charset=utf-8

And the site that does compress has:

Content-Type: application/x-javascript

My gzip config is as follows:
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/css application/json
application/x-javascript text/xml application/xml application/xml+rss
text/javascript;

How do I get nginx to gzip content for the first site? It should ignore
the charset which should not matter in this case.


#2

On Sat, May 02, 2009 at 12:26:25AM +0200, Joe Bofh wrote:

How do I get nginx to gzip content for the first site? It should ignore
the charset which should not matter in this case.

nginx ignores charset when gzipping. Where does this response come from
?
Is it a static response or a proxied one ?


#3

It comes from PHP

Igor S. wrote:

On Sat, May 02, 2009 at 12:26:25AM +0200, Joe Bofh wrote:

How do I get nginx to gzip content for the first site? It should ignore
the charset which should not matter in this case.

nginx ignores charset when gzipping. Where does this response come from
?
Is it a static response or a proxied one ?


#4

On Sat, May 02, 2009 at 09:03:57AM +0200, Joe Bofh wrote:

It comes from PHP

Could you create debug log ?


#5

How do I do so? Thanks.

Igor S. wrote:

On Sat, May 02, 2009 at 09:03:57AM +0200, Joe Bofh wrote:

It comes from PHP

Could you create debug log ?


#6

On Sun, May 03, 2009 at 05:05:45AM +0200, Joe Bofh wrote:

How do I do so? Thanks.

./configure --with-debug …

nginx.conf:

events {
debug_connection your.ip.address;
}


#7

Command used was:

curl -I --compressed
http://crm/themes/cookie.js?s=010bb46bf39847ae07d0ffe69af0ea0e&c=1

This is the debug

2009/05/03 14:41:53 [debug] 26199#0: *25 malloc: 0812D680:1024
2009/05/03 14:41:53 [debug] 26199#0: *25 malloc: 080F8B88:4096
2009/05/03 14:41:53 [debug] 26199#0: *25 http process request line
2009/05/03 14:41:53 [debug] 26199#0: *25 recv: fd:18 234 of 1024
2009/05/03 14:41:53 [debug] 26199#0: *25 http request line: “HEAD
/themes/cookie.js?s=010bb46bf39847ae07d0ffe69af0ea0e&c=1 HTTP/1.1”
2009/05/03 14:41:53 [debug] 26199#0: *25 http uri: “/themes/cookie.js”
2009/05/03 14:41:53 [debug] 26199#0: *25 http args:
“s=010bb46bf39847ae07d0ffe69af0ea0e&c=1”
2009/05/03 14:41:53 [debug] 26199#0: *25 http exten: “js”
2009/05/03 14:41:53 [debug] 26199#0: *25 http process request header
line
2009/05/03 14:41:53 [debug] 26199#0: *25 http header: “User-Agent:
curl/7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l
zlib/1.2.3”
2009/05/03 14:41:53 [debug] 26199#0: *25 http header: “Host: crm”
2009/05/03 14:41:53 [debug] 26199#0: *25 http header: “Accept: /
2009/05/03 14:41:53 [debug] 26199#0: *25 http header: “Accept-Encoding:
deflate, gzip”
2009/05/03 14:41:53 [debug] 26199#0: *25 http header done
2009/05/03 14:41:53 [debug] 26199#0: *25 event timer del: 18: 141424591
2009/05/03 14:41:53 [debug] 26199#0: *25 generic phase: 0
2009/05/03 14:41:53 [debug] 26199#0: *25 test location: “/”
2009/05/03 14:41:53 [debug] 26199#0: *25 test location: ~
“^.+.(jpg|jpeg|gif|png|ico)$”
2009/05/03 14:41:53 [debug] 26199#0: *25 test location: ~
“^.+.(css|js)$”
2009/05/03 14:41:53 [debug] 26199#0: *25 using configuration
“^.+.(css|js)$”
2009/05/03 14:41:53 [debug] 26199#0: *25 http cl:-1 max:10485760
2009/05/03 14:41:53 [debug] 26199#0: *25 generic phase: 2
2009/05/03 14:41:53 [debug] 26199#0: *25 post rewrite phase: 3
2009/05/03 14:41:53 [debug] 26199#0: *25 generic phase: 4
2009/05/03 14:41:53 [debug] 26199#0: *25 generic phase: 5
2009/05/03 14:41:53 [debug] 26199#0: *25 access phase: 6
2009/05/03 14:41:53 [debug] 26199#0: *25 access phase: 7
2009/05/03 14:41:53 [debug] 26199#0: *25 post access phase: 8
2009/05/03 14:41:53 [debug] 26199#0: *25 try files phase: 9
2009/05/03 14:41:53 [debug] 26199#0: *25 content phase: 10
2009/05/03 14:41:53 [debug] 26199#0: *25 content phase: 11
2009/05/03 14:41:53 [debug] 26199#0: *25 content phase: 12
2009/05/03 14:41:53 [debug] 26199#0: *25 http filename:
“/var/www/crm/themes/cookie.js.gz”
2009/05/03 14:41:53 [debug] 26199#0: *25 add cleanup: 080F9220
2009/05/03 14:41:53 [debug] 26199#0: *25 cached open file:
/var/www/crm/themes/cookie.js.gz, fd:-1, c:0, e:2, u:3
2009/05/03 14:41:53 [debug] 26199#0: *25 content phase: 13
2009/05/03 14:41:53 [debug] 26199#0: *25 http filename:
“/var/www/crm/themes/cookie.js”
2009/05/03 14:41:53 [debug] 26199#0: *25 add cleanup: 080F9268
2009/05/03 14:41:53 [debug] 26199#0: *25 retest open file:
/var/www/crm/themes/cookie.js, fd:19, c:0, e:0
2009/05/03 14:41:53 [debug] 26199#0: *25 cached open file:
/var/www/crm/themes/cookie.js, fd:19, c:1, e:0, u:3
2009/05/03 14:41:53 [debug] 26199#0: *25 http static fd: 19
2009/05/03 14:41:53 [debug] 26199#0: *25 http set discard body
2009/05/03 14:41:53 [debug] 26199#0: *25 HTTP/1.1 200 OK
Server: Hai
Date: Sun, 03 May 2009 21:41:53 GMT
Content-Type: application/x-javascript; charset=utf-8
Content-Length: 2719
Last-Modified: Thu, 23 Apr 2009 04:30:47 GMT
Connection: keep-alive
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Accept-Ranges: bytes

2009/05/03 14:41:53 [debug] 26199#0: *25 write new buf t:1 f:0 080F938C,
pos 080F938C, size: 312 file: 0, size: 0
2009/05/03 14:41:53 [debug] 26199#0: *25 http write filter: l:1 f:0
s:312
2009/05/03 14:41:53 [debug] 26199#0: *25 http write filter limit 0
2009/05/03 14:41:53 [debug] 26199#0: *25 writev: 312
2009/05/03 14:41:53 [debug] 26199#0: *25 http write filter 00000000
2009/05/03 14:41:53 [debug] 26199#0: *25 http finalize request: 0,
“/themes/cookie.js?s=010bb46bf39847ae07d0ffe69af0ea0e&c=1” 1
2009/05/03 14:41:53 [debug] 26199#0: *25 set http keepalive handler
2009/05/03 14:41:53 [debug] 26199#0: *25 http close request
2009/05/03 14:41:53 [debug] 26199#0: *25 http log handler
2009/05/03 14:41:53 [debug] 26199#0: *25 run cleanup: 080F9268
2009/05/03 14:41:53 [debug] 26199#0: *25 close cached open file:
/var/www/crm/themes/cookie.js, fd:19, c:0, u:3, 0
2009/05/03 14:41:53 [debug] 26199#0: *25 expire cached open file:
/var/www/crm/themes/Sugar/colors.sugar.icon.gif.gz
2009/05/03 14:41:53 [debug] 26199#0: *25 expire cached open file:
/var/www/crm/themes/Sugar/colors.sugar.icon.gif
2009/05/03 14:41:53 [debug] 26199#0: *25 close cached open file:
/var/www/crm/themes/Sugar/colors.sugar.icon.gif, fd:-1, c:0, u:1, 1
2009/05/03 14:41:53 [debug] 26199#0: *25 free: 080F8B88, unused: 1708
2009/05/03 14:41:53 [debug] 26199#0: *25 event timer add: 18:
60000:141424591
2009/05/03 14:41:53 [debug] 26199#0: *25 free: 080D7E98
2009/05/03 14:41:53 [debug] 26199#0: *25 free: 0812D680
2009/05/03 14:41:53 [debug] 26199#0: *25 hc free: 00000000 0
2009/05/03 14:41:53 [debug] 26199#0: *25 hc busy: 00000000 0
2009/05/03 14:41:53 [debug] 26199#0: *25 post event B7895174
2009/05/03 14:41:53 [debug] 26199#0: *25 delete posted event B7895174
2009/05/03 14:41:53 [debug] 26199#0: *25 http keepalive handler
2009/05/03 14:41:53 [debug] 26199#0: *25 malloc: 080D7E98:1024
2009/05/03 14:41:53 [debug] 26199#0: *25 recv: fd:18 -1 of 1024
2009/05/03 14:41:53 [debug] 26199#0: *25 recv() not ready (11: Resource
temporarily unavailable)
2009/05/03 14:41:53 [debug] 26199#0: *25 post event B7895174
2009/05/03 14:41:53 [debug] 26199#0: *25 delete posted event B7895174
2009/05/03 14:41:53 [debug] 26199#0: *25 http keepalive handler
2009/05/03 14:41:53 [debug] 26199#0: *25 recv: fd:18 0 of 1024
2009/05/03 14:41:53 [info] 26199#0: *25 client 192.168.1.1 closed
keepalive connection
2009/05/03 14:41:53 [debug] 26199#0: *25 close http connection: 18
2009/05/03 14:41:53 [debug] 26199#0: *25 event timer del: 18: 141424591
2009/05/03 14:41:53 [debug] 26199#0: *25 free: 080D7E98
2009/05/03 14:41:53 [debug] 26199#0: *25 free: 00000000
2009/05/03 14:41:53 [debug] 26199#0: *25 free: 00000000
2009/05/03 14:41:53 [debug] 26199#0: *25 free: 0812CD20, unused: 52


#8

Sorry,

This is my mistake. I just figured it out. I had accidentally set gzip
to off in this particular conf file as it was copied from another setup.

I fixed it and now it works as expected.