Rack::Brotli
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 Chrome, Firefox, IE and Opera.
Use
Install gem:
gem install rack-brotli
Requiring 'rack/brotli'
will autoload 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
Testing
To run the entire test suite, run
bundle exec rake test
Links
- rack-brotli: http://github.com/marcotc/rack-brotli
- Brotli for Ruby: https://github.com/miyucy/brotli
- Rack: http://github.com/rack/rack