code-dot-org/code-dot-org — pull request #97 by wjordan (2014-10-02 22:22:25+00:00)
Title: use heroku_rails_deflate gem in server environments

adds Rack::Deflater middleware and serves gzip assets generated by assets:precompile

This gem doesn't seem to have heroku-specific configuration- it's just called 'heroku' because it has a configuration suitable for Heroku's web stack in ways similar to our own. from the [README](https://github.com/mattolson/heroku_rails_deflate):
>The Heroku Cedar stack is not fronted by an asset server such as Varnish or nginx, and there is no automatic provision for using gzip compression for HTTP transfers.

this is effectively the same as our own web stack (our Varnish cache does not serve static assets itself or do any of its own gzip compression).

It's better than straight Rack::Deflater because it includes middleware to serve static gzip files for precompiled assets. from the README:
>the real coolness is the custom middleware that checks for the .gz version of precompiled assets and serves them up for you.

I've configured it to activate in staging, test and production since we don't serve precompiled assets in development mode, and plan to test that it works properly as soon as it's pushed to staging.