2020-01-24 12:47:52 -07:00
|
|
|
---
|
|
|
|
title: encode (Caddyfile directive)
|
|
|
|
---
|
|
|
|
|
|
|
|
# encode
|
|
|
|
|
|
|
|
Encodes responses using the configured encoding(s). A typical use for encoding is compression.
|
|
|
|
|
|
|
|
## Syntax
|
|
|
|
|
2020-05-17 16:32:12 -04:00
|
|
|
```caddy-d
|
2020-01-24 12:47:52 -07:00
|
|
|
encode [<matcher>] <formats...> {
|
|
|
|
gzip [<level>]
|
|
|
|
zstd
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
- **<formats...>** is the list of encoding formats to enable.
|
|
|
|
- **gzip** enables Gzip compression, optionally at the specified level.
|
|
|
|
- **zstd** enables Zstandard compression.
|
|
|
|
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
Enable Gzip compression:
|
|
|
|
|
2020-05-17 16:32:12 -04:00
|
|
|
```caddy-d
|
2020-01-24 12:47:52 -07:00
|
|
|
encode gzip
|
|
|
|
```
|
|
|
|
|
|
|
|
Enable Zstandard and Gzip compression:
|
|
|
|
|
2020-05-17 16:32:12 -04:00
|
|
|
```caddy-d
|
2020-01-24 12:47:52 -07:00
|
|
|
encode zstd gzip
|
|
|
|
```
|
|
|
|
|