rails/rails — pull request #8669 by jbaudanza (2013-01-01 02:42:59+00:00)
Title: ActionDispatch::Static serves precompressed assets

Sprockets currently generates gzipped javascript and css files next to their uncompressed counterparts. However, to take advantage of this you need to use an nginx extension or something similar.

This patch will allow ActionDispatch::Static to serve up these gzipped files when appropriate.

For example, this request:

curl -H "Accept-Encoding: gzip" http://localhost:3000/assets/application.js

Will look for application.js.gz on disk and respond with:

HTTP/1.1 200 OK
Content-Type: application/javascript
Content-Encoding: gzip
Content-Length: 1234
More-Headers...

This is particularly helpful for environments like Heroku, that depend on ActionDispatch::Static to serve static assets. Currently, the only way to serve gzipped assets in this environment is to install Rack::Deflate ahead of ActionDispatch::Static. This is undesirable, because Rack::Deflate compresses everything, including compressed assets like images and swfs.