Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ueffel/caddy-brotli
Brotli compression encoder for Caddy
https://github.com/ueffel/caddy-brotli
brotli brotli-compression caddy caddy-module caddy-plugin caddyserver compression go
Last synced: 15 days ago
JSON representation
Brotli compression encoder for Caddy
- Host: GitHub
- URL: https://github.com/ueffel/caddy-brotli
- Owner: ueffel
- License: mit
- Created: 2020-08-23T15:17:05.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-05-02T13:39:52.000Z (7 months ago)
- Last Synced: 2024-08-02T15:48:04.341Z (4 months ago)
- Topics: brotli, brotli-compression, caddy, caddy-module, caddy-plugin, caddyserver, compression, go
- Language: Go
- Homepage:
- Size: 204 KB
- Stars: 43
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Brotli for Caddy
This package implements a brotli encoder for [Caddy](https://caddyserver.com/).
Requires Caddy 2+.
Uses the pure go brotli implementation
This implementation is NOT high performance, so it is not recommended to use this encoding as
primary compression algorithm. Use gzip instead.## Installation
```sh
xcaddy build --with github.com/ueffel/caddy-brotli
```## Syntax
There will be the new encoding `br` available within the
[encode directive](https://caddyserver.com/docs/caddyfile/directives/encode)```caddyfile
encode [] {
br []
}
````level` controls the compression level (ranges from 0 to 11), default is 4.
Example usages could look like this:
```caddyfile
encode br
``````caddyfile
encode {
br 4
}
```or together with gzip
```caddyfile
encode gzip br
``````caddyfile
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
>
> ```caddyfile
> encode gzip br
> ```
>
> * Request:
>
> ```plain
> [...]
> Accept-Encoding: deflate, gzip, br
> [...]
> ```
>
> Response will be:
>
> ```plain
> [...]
> Content-Encoding: gzip
> [...]
> ```
>
> * Request: (different order of encodings)
>
> ```plain
> [...]
> Accept-Encoding: deflate, br, gzip
> [...]
> ```
>
> Response will be:
>
> ```plain
> [...]
> Content-Encoding: br
> [...]
> ```