‘Output Compression’ by Tom Fakes is a Ruby on Rails plugin that allows GZIP output compression for clients that support it.
GZIP compression is a common way to compress the content of web pages by the server before the request is passed on to the browser. The browser decompresses the content and renders it. This method needs less data passing over the network, up to 55% in my case, but has a small performance hit as both the server and the browser need to (de)compress the package.
The Ruby on Rails plugin is great but at the time of writing (in Ruby 1.8.2) it's broken and needs some manual fixing... lets fix it.
Open the output_compression.rb file in the vendor/plugins/output_compression/lib/ folder and move the “alias :original_request_for_component :request_for_component” line below the request_for_component one. At first it should look like this:
The end result should look like this:
Lastly you need to add the following line in the controller you would like to enable GZIP for. I chose to put this in my application controller (application.rb) to enable compression for all my pages:
This post is open source. Did you spot a mistake? Ideas for improvements? Contribute to this post via Github. Thank you!