How to Enable Gzip Compression on Heroku

gzip compression
gzip compression 
This post assumed you're familiar with Heroku environment, especially with their CLI tools : Heroku toolbelt. Beside, you can find out what is gzip compression here

The benefits of using gzip compression.
Your site performance will be increased. Your site's page size which is loaded to user's web browser will become smaller.

If you hosted your site on Heroku, you need to enable gzip compression by yourself. It's not enabled by default. You'll find it out when measuring your application performance with PageSpeed or YSlow.

How to enable Gzip compression on your Heroku application ?
  • Install heroku-deflater gem.
  • Don't forget to install it for production environment only.
In case you want to test it on your staging site or even on your local development box, make sure you have added this code to respected environment file (That is: staging is staging.rb and development is development.rb)
config.static_cache_control = "public, max-age=3600"

Otherwise, you will see an error when starting the server instance. Therefore, make sure you have it on your production.rb file too.