Compress Responses Using Rack::Deflater On Rails

Posted by Weston Ganger on April 14, 2016

You can easily compress your responses from your Rails app with a one-liner. No additional gems required.

This comes at a very small cost to response time but can reduce your responses size by about 10x.

Heres how to set it up in Rails:

# config/application.rb

# This must come before some other middlewares such as JSONP
config.middleware.use Rack::Deflater

You can also add this to any Rack Application

use Rack::Deflater
run MyApp::Instance

Related External Links:

Posted in Rails and Tagged with rails rack 

Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts