Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/docs/markdown/caddyfile-tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ It's good practice to compress responses with a quick and modern compression alg
```caddy
localhost

encode zstd gzip
encode
templates
file_server browse
```
Expand All @@ -156,7 +156,7 @@ Our Caddyfile so far:
```caddy
localhost

encode zstd gzip
encode
templates
file_server browse
```
Expand All @@ -165,7 +165,7 @@ is equivalent to this one:

```caddy
localhost {
encode zstd gzip
encode
templates
file_server browse
}
Expand Down
2 changes: 1 addition & 1 deletion src/docs/markdown/caddyfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ It looks like this:
```caddy
example.com {
root * /var/www/wordpress
encode gzip
encode
php_fastcgi unix//run/php/php-version-fpm.sock
file_server
}
Expand Down
12 changes: 9 additions & 3 deletions src/docs/markdown/caddyfile/directives/encode.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Encodes responses using the configured encoding(s). A typical use for encoding i
## Syntax

```caddy-d
encode [<matcher>] <formats...> {
encode [<matcher>] [<formats...>] {
# encoding formats
gzip [<level>]
zstd [<level>]
Expand All @@ -36,7 +36,7 @@ encode [<matcher>] <formats...> {
}
```

- **&lt;formats...&gt;** is the list of encoding formats to enable. If multiple encodings are enabled, the encoding is chosen based the request's Accept-Encoding header; if the client has no strong preference (q-factor), then the first supported encoding is used.
- **&lt;formats...&gt;** is the list of encoding formats to enable. If multiple encodings are enabled, the encoding is chosen based the request's Accept-Encoding header; if the client has no strong preference (q-factor), then the first supported encoding is used. If omitted, `zstd` (preferred) and `gzip` are enabled by default.

- **gzip** <span id="gzip"/> enables Gzip compression, optionally at a specified level.

Expand Down Expand Up @@ -99,12 +99,18 @@ Enable Zstandard and Gzip compression (with Zstandard implicitly preferred, sinc
encode zstd gzip
```

As this is the default value, the previous configuration is strictly equivalent to:

```caddy-d
encode
```

And in a full site, compressing static files served by [`file_server`](file_server):

```caddy
example.com {
root * /srv
encode zstd gzip
encode
file_server
}
```
6 changes: 3 additions & 3 deletions src/docs/markdown/caddyfile/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ With a PHP FastCGI service running, something like this works for most modern PH
```caddy
example.com {
root * /srv/public
encode gzip
encode
php_fastcgi localhost:9000
file_server
}
Expand Down Expand Up @@ -217,7 +217,7 @@ A typical SPA config usually looks something like this:
```caddy
example.com {
root * /srv
encode gzip
encode
try_files {path} /index.html
file_server
}
Expand All @@ -227,7 +227,7 @@ If your SPA is coupled with an API or other server-side-only endpoints, you will

```caddy
example.com {
encode gzip
encode

handle /api/* {
reverse_proxy backend:8000
Expand Down