Slim down HTTP responses
If you're using a Rack-based web framework you can very easily slim down your responses by compressing them.
To achieve this you just have to use the Rack::Deflater middleware, like so:
# config.ru
require 'rack'
require './app'
use Rack::Deflater
run Sinatra::Application
Yes, that's all there is to it!
Now any client that sets the Accept-Encoding: gzip,deflate
header will benefit from smaller responses.
Written by Ricardo Mendes
Related protips
2 Responses

Thanks for this, now I wonder how could be possible to make Rack::Deflater add the Vary: Accept-Encoding header. Have you found this out yet?
over 1 year ago
·

Thanks
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#