mirror of
https://github.com/caddyserver/website.git
synced 2025-04-20 04:15:04 -04:00
docs: encode short syntax (#445)
This commit is contained in:
parent
ef31c7646a
commit
ff1088fd1f
4 changed files with 16 additions and 10 deletions
|
@ -134,7 +134,7 @@ It's good practice to compress responses with a quick and modern compression alg
|
||||||
```caddy
|
```caddy
|
||||||
localhost
|
localhost
|
||||||
|
|
||||||
encode zstd gzip
|
encode
|
||||||
templates
|
templates
|
||||||
file_server browse
|
file_server browse
|
||||||
```
|
```
|
||||||
|
@ -156,7 +156,7 @@ Our Caddyfile so far:
|
||||||
```caddy
|
```caddy
|
||||||
localhost
|
localhost
|
||||||
|
|
||||||
encode zstd gzip
|
encode
|
||||||
templates
|
templates
|
||||||
file_server browse
|
file_server browse
|
||||||
```
|
```
|
||||||
|
@ -165,7 +165,7 @@ is equivalent to this one:
|
||||||
|
|
||||||
```caddy
|
```caddy
|
||||||
localhost {
|
localhost {
|
||||||
encode zstd gzip
|
encode
|
||||||
templates
|
templates
|
||||||
file_server browse
|
file_server browse
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ It looks like this:
|
||||||
```caddy
|
```caddy
|
||||||
example.com {
|
example.com {
|
||||||
root * /var/www/wordpress
|
root * /var/www/wordpress
|
||||||
encode gzip
|
encode
|
||||||
php_fastcgi unix//run/php/php-version-fpm.sock
|
php_fastcgi unix//run/php/php-version-fpm.sock
|
||||||
file_server
|
file_server
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ Encodes responses using the configured encoding(s). A typical use for encoding i
|
||||||
## Syntax
|
## Syntax
|
||||||
|
|
||||||
```caddy-d
|
```caddy-d
|
||||||
encode [<matcher>] <formats...> {
|
encode [<matcher>] [<formats...>] {
|
||||||
# encoding formats
|
# encoding formats
|
||||||
gzip [<level>]
|
gzip [<level>]
|
||||||
zstd [<level>]
|
zstd [<level>]
|
||||||
|
@ -36,7 +36,7 @@ encode [<matcher>] <formats...> {
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
- **<formats...>** 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.
|
- **<formats...>** 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.
|
- **gzip** <span id="gzip"/> enables Gzip compression, optionally at a specified level.
|
||||||
|
|
||||||
|
@ -99,12 +99,18 @@ Enable Zstandard and Gzip compression (with Zstandard implicitly preferred, sinc
|
||||||
encode zstd gzip
|
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):
|
And in a full site, compressing static files served by [`file_server`](file_server):
|
||||||
|
|
||||||
```caddy
|
```caddy
|
||||||
example.com {
|
example.com {
|
||||||
root * /srv
|
root * /srv
|
||||||
encode zstd gzip
|
encode
|
||||||
file_server
|
file_server
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -66,7 +66,7 @@ With a PHP FastCGI service running, something like this works for most modern PH
|
||||||
```caddy
|
```caddy
|
||||||
example.com {
|
example.com {
|
||||||
root * /srv/public
|
root * /srv/public
|
||||||
encode gzip
|
encode
|
||||||
php_fastcgi localhost:9000
|
php_fastcgi localhost:9000
|
||||||
file_server
|
file_server
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ A typical SPA config usually looks something like this:
|
||||||
```caddy
|
```caddy
|
||||||
example.com {
|
example.com {
|
||||||
root * /srv
|
root * /srv
|
||||||
encode gzip
|
encode
|
||||||
try_files {path} /index.html
|
try_files {path} /index.html
|
||||||
file_server
|
file_server
|
||||||
}
|
}
|
||||||
|
@ -227,7 +227,7 @@ If your SPA is coupled with an API or other server-side-only endpoints, you will
|
||||||
|
|
||||||
```caddy
|
```caddy
|
||||||
example.com {
|
example.com {
|
||||||
encode gzip
|
encode
|
||||||
|
|
||||||
handle /api/* {
|
handle /api/* {
|
||||||
reverse_proxy backend:8000
|
reverse_proxy backend:8000
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue