Heroku is the popular ruby on rails PAAS hosting platform. With the earlier versions, if you were hosting a rails web application on it. All apps deployed to Heroku used to automatically compress pages they serve, by passing through Nginx’s gzip filter on the way out. But with their newest Cedar Stack, things have changed
In Cedar, the HTTP requests terminates directly at your app server & no longer goes through a proxy server(Nginx), hence there can’t be automatic gzip compression. More information about this can be found in HTTP routing dev center article So we have to manage gzip compression on our own. fortunately, this is trivial as adding just one line to your config. basically, you will need to use Rack::Deflater & make sure that it get loaded before ActionDispatch::Static. The simplest way to enable gzip compression in Rails 3.2 is by adding “use Rack::Deflater” in config.ru file.
After the change, this how your config.ru file should look like:
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
use Rack::Deflater
run Improvingoutcomes::Application
I spending sometime gather information about this. So Hope this post help you save some time.
 
thanks. was looking out for this. great tutorial
Brilliant! Thanks!
I’m using Rails 3.0.9
is it possible to use that configuration ?
LMK
Thanks a lot ! I can’t believe Heroku (even paid environment) doesn’t support this out of the box. Google Page Speed detected this problem and your solution helped me reduce page load by 75% ! (lot of bootstrap css and js and images on landing page)
You can also look at a gem like https://github.com/romanbsd/heroku-deflater
If you’re using the asset pipeline properly, heroku will precompile all of your assets and create gzipped versions when you deploy. Heroku-deflater checks for these, instead of deflating files on every request.