Content Compression via Rack::Deflater,Rails and Ngnix

I have followed this content-compression-with-rack-deflater.

In my ngnix.conf

  gzip on;
  gzip_http_version 1.0;
  gzip_proxied any;
  # See [http://wiki.nginx.org/NginxHttpGzipModule#gzip_types](http://wiki.nginx.org/NginxHttpGzipModule#gzip_types)
  # This gets rid of a warning about repeated text/html
  gzip_types text/plain text/xml text/css
         text/comma-separated-values
         text/javascript application/x-javascript
         application/atom+xml;

I have restarted both servers,But the response is coming like this.

Ҳ�t��₎�U�O�Z�+�x�j����X����R�-

�[ϗ��3Y�J{��阧s5���/������7��ߣs>3�N4�9�u!�.G�ThvMg�.rFj@�
Am using ngnix with openresty,unicorn and rails 3.2,Please see my request and response headers.
Request Header:
Accept text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Cache-Control no-cache
Connection keep-alive
Cookie locale=en; _Microsite_session=3bpa2ja8gb17
Host mylocal-admin
Pragma no-cache
User-Agent Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0
Response Header

Cache-Control    max-age=0, private, must-revalidate
Connection    keep-alive
Content-Encoding    gzip
Content-Type    text/html; charset=utf-8
Date    Thu, 22 Jan 2015 12:35:12 GMT
Etag    "3445b84f524a0746633c15"
Server    nginx
Status    200 OK
Transfer-Encoding    chunked
Vary    Accept-Encoding
X-Request-Id    7b448590af53df7a6d91c
X-Runtime    2.599340
X-UA-Compatible    IE=Edge

Could anyone please help me to solve this issue.

I have restarted both servers,But the response is coming like this.

Ҳ�t��₎�U�O�Z�+�x�j����X����R�-
�[ϗ��3Y�J{��阧s5���/������7��ߣs>3�N4�9�u!�.G�ThvMg�.rFj@�

Am using ngnix with openresty,unicorn and rails 3.2,Please see my request and response headers.

Hi kingston,

maybe I’m wrong but I think that you are compressing the same html 2 times: first your Rack compress and send via Puma, then your nginx get this and compress again. The browser only decompress 1 time and think that the result is the final text. Try to disable your ngnix compression and check if in the “Response Header”, the “Content-Encoding” will still getting a “gzip” result. Also, for your assets, its better to use the precompiled gzip that Rails produces than compile on-the-fly - this will reduce your server load considerably (check the 4.1.2 item - “GZip Compression”: http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets).

Thanks for you reply Loureiro

I have disabled nginx compression and checked but result is same.

Thanks,
Kingston.s