4kn4zw
Last Updated: December 29, 2017
·
3.051K
· locks
47106c89a2c15b92fe3d966af3337236

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.

Say Thanks
Respond

2 Responses
Add your response

13408
7feb6f36a6b750315e7fb540e1ab501a

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 ·
18071
None

Thanks

over 1 year ago ·