0.04
A long-lived project that still receives updates
Rack::Brotli enables Google's Brotli compression on HTTP responses
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0.3
>= 3
 Project Readme

Rack::Brotli Gem Version Build Status

Brötli, the Swiss German word for a bread roll, on a Rack with some Ruby decorations

Rack::Brotli compresses Rack responses using Google's Brotli compression algorithm.

Brotli generally compresses better than gzip for the same CPU cost and is supported by pretty much everywhere.

Use

Install gem:

gem install rack-brotli

Requiring 'rack/brotli' will autoload the Rack::Brotli module.

The following example shows what a simple rackup (config.ru) file might look like:

require 'rack'
require 'rack/brotli'

use Rack::Brotli # Default compression quality is 5

# You can also provide native Brotli compression options:
# use Rack::Brotli, quality: 11

run theapp

For a Ruby on Rails application, add to your config/application.rb:

config.middleware.use Rack::Deflater
# Rack::Brotli goes directly under Rack::Deflater, if Rack::Deflater is present
config.middleware.use Rack::Brotli

Testing

To run the entire test suite, run

bundle exec rake test

Links