title: Amazon S3 and Cloudfront don't gzip on-fly
body: <p>I want to use new feature in Cloudfront, which allows to gzip files on-fly using <em>Accept-Encoding: gzip</em> header. I set up my CDN distribution, turned on "Compress Objects Automatically", whitelisted headers: Origin, Accept-Control-Request-Headers and Accept-Control-Request-Method (I'm using AngularJS, I need it for OPTIONS method). I dont have any CORS set on my S3 bucket.</p>
  
  <p>As stated in their docs, it should start working when I add <em>Accept-Encoding: gzip</em> header to the request. However, I'm still getting raw file.</p>
  
  <pre><code>Response Headers
  
  Accept-Ranges:bytes
  Age:65505
  Cache-Control:public, max-age=31557600
  Connection:keep-alive
  Content-Length:408016
  Content-Type:text/css
  Date:Mon, 21 Mar 2016 16:00:36 GMT
  ETag:"5a04faf838d5165f24ebcba54eb5fbac"
  Expires:Tue, 21 Mar 2017 21:59:21 GMT
  Last-Modified:Mon, 21 Mar 2016 15:59:22 GMT
  Server:AmazonS3
  Via:1.1 0e6067b46ed4b3e688f898d03e5c1c67.cloudfront.net (CloudFront)
  X-Amz-Cf-Id:gKYTTq0cIcUvHTtlrdMig8D1R2ZVdea4EnflV0-IxhtaxgRvLYj6LQ==
  X-Cache:Hit from cloudfront
  
  Request Headers
  
  Accept:text/css,*/*;q=0.1
  Accept-Encoding:gzip, deflate, sdch
  Accept-Language:pl,en-US;q=0.8,en;q=0.6
  Cache-Control:max-age=0
  Connection:keep-alive
  Host: XXX.cloudfront.net
  Referer: XXX
  User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36
  </code></pre>
  
  <p>My configuration is:</p>
  
  <ul>
  <li>Rails with Angular on Unicorn (using asset_sync)</li>
  <li>Nginx</li>
  <li>S3 and Cloudfront</li>
  </ul>