Take the 2-minute tour ×

I have an nginx + passenger installed on Amazon Linux EC2 server, running a Rails application. The application yields JSON responses.

The JSON response is rendered with length header:

# test_controller.rb
# result contains a large 400k JSON string
headers["Content-Length"] = result.size.to_s
render :json => result

I tried enabling gzip, but the response is still not compressed. I checked it with GIDZipTest.

# nginx.conf
gzip on;
gzip_http_version 1.1;
gzip_comp_level 1;
gzip_proxied any;
gzip_vary on;
gzip_min_length 500;
gzip_types application/x-javascript  application/json;
share|improve this question
add comment

2 Answers

I have it working properly, try adding (text/javascript)

share|improve this answer
Sorry, still the same. I am sure it may help in other cases, probably something else is not configured right. If it's any help - nginx is also configured to upstream fcgi applications. –  Tal Yaniv Jan 2 '12 at 21:35
add comment

Mystery solved. The php script is not reliable.

This is reliable:

wget --header="accept-encoding: gzip" URL

Gets the compressed version.

Testing with Chrome and Charles sniffer convinced me that everything worked fine.

share|improve this answer
add comment

Your Answer


