How to gzip an Ember CLI + Rails app on Heroku

Monday, August 25th 2014

I've been rebuilding my blog to have an ember front end and a rails backend (you're currently on it, but shhhhh it's not final).

Before gzipping everything my assets weighed in around 700kb. Which is a lot for a blog site that has almost nothing really to it.

How to gzip heroku?!

It's up to you to handle your asset gzipping when you're hosting on heroku. After trying out 3 different gems and playing around with some broccoli plugins I found a super simple soultion that brings my total site weight down to 249kb. NICE! Here are the two easy steps I took to get that:

  • In your config/envoriments/production file add this line: config.middleware.use Rack::Deflater
  • In your config.ru file add use Rack::Deflater.

My whole config.ru file looks like this:

# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment',  __FILE__)
use Rack::Deflater
run Rails.application

You can checkout my production config file here.

After those changes you're well on your way to having nice gzipped assets! Yay!