I have rails 3.2.1 application and nginx.
In nginx configurations I set gzip on;
, and compressing works for pages, css, js files.
But it does not work for JSON responses. As I found the solution for rails is to add: config.middleware.use Rack::Deflater
into application.rb.
And it helps: before response was 45Kb, now near 8Kb.
But, now I found that compression works only in Mac Chrome, Mac Firefox and Windows Chrome.
For IE 10, IE 11 and Windows Firefox - it does not work:
- I see
Accept-Encoding: gzip, deflate
in request-header, - I don't see
Content-Encoding: gzip
in response-header, - response size is still 45Kb.
Please, help.
Fixed by moving compressing configurations from rails to nginx configs. I added to
<my_site>.conf
:Thanks @Alexey Ten for help.
It works, but compressing are not visible in IE. Some security programs on Windows catch "gzipped" HTTP-responses, extract it from archive, check for viruses and also remove
Content-Encoding: gzip
from header of response. IE as usual excelled :)