项目作者: ueffel

项目描述 :
Brotli compression encoder for Caddy
高级语言: Go
项目地址: git://github.com/ueffel/caddy-brotli.git
创建时间: 2020-08-23T15:17:05Z
项目社区:https://github.com/ueffel/caddy-brotli

开源协议:MIT License

下载


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 instead.

Installation

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

Syntax

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

  1. encode [<matcher>] <formats...> {
  2. br [<level>]
  3. }

level controls the compression level (ranges from 0 to 11), default is 4.

Example usages could look like this:

  1. encode br
  1. encode {
  2. br 4
  3. }

or together with gzip

  1. encode gzip br
  1. encode {
  2. gzip 5
  3. br 4
  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

  1. encode gzip br
  • Request:

    1. [...]
    2. Accept-Encoding: deflate, gzip, br
    3. [...]

    Response will be:

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

    1. [...]
    2. Accept-Encoding: deflate, br, gzip
    3. [...]

    Response will be:

    1. [...]
    2. Content-Encoding: br
    3. [...]