Coder Social home page Coder Social logo

caddy-brotli's Introduction

Brotli for Caddy

This package implements a brotli encoder for Caddy.

Requires Caddy 2+.

Uses the pure go brotli implementation https://github.com/andybalholm/brotli

This implementation is NOT high performance, so it is not recommended to use this encoding as primary compression algorithm. Use gzip or zstd instead.

The new matchfinder algorithm implementation in andybalholm/brotli is also supported, use with v2.

Currently they [new compression algorithms] give better results than the old implementation (at least for compressing my test file, Newton’s Opticks) on levels 2 to 7.

quoted from the README of https://github.com/andybalholm/brotli.

Installation

xcaddy build --with github.com/ueffel/caddy-brotli

Syntax

There will be the new encoding br available within the encode directive

encode [<matcher>] <formats...> {
    br [[<level>] [v2]]
}
  • level controls the compression level (ranges from 0 to 11), default is 4.
    for the new algorithm (v2) the levels range from 2 to 7, default is also 4.
  • v2 if set the new brotli algorithm is used

Example usages could look like this:

encode br
encode {
    br 4
}
encode {
    br v2
}
encode {
    br 4 v2
}

or together with other encodings like gzip

encode gzip br
encode {
    gzip 5
    br 4
}

Remarks

Update 2: From Caddy v2.4.0 onwards preferred order is implied by definition order.

Update: Since Caddy v2.4.0-beta.2 the preferred order of encodings can be set via prefer setting.

There is currently no way to set a prefered order of content-encodings via caddy's configuration. The content-encoding is determined by the clients preference. In most cases that means a response is encoded with the first accepted encoding in the Accept-Encoding header of the request that the caddy also supports.

Example:

Caddyfile

encode gzip br
  • Request:

    [...]
    Accept-Encoding: deflate, gzip, br
    [...]
    

    Response will be:

    [...]
    Content-Encoding: gzip
    [...]
    
  • Request: (different order of encodings)

    [...]
    Accept-Encoding: deflate, br, gzip
    [...]
    

    Response will be:

    [...]
    Content-Encoding: br
    [...]
    

caddy-brotli's People

Contributors

ueffel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ahn254 480

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.