mirror of
https://github.com/caddyserver/website.git
synced 2025-04-24 05:56:15 -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
|
||||
localhost
|
||||
|
||||
encode zstd gzip
|
||||
encode
|
||||
templates
|
||||
file_server browse
|
||||
```
|
||||
|
@ -156,7 +156,7 @@ Our Caddyfile so far:
|
|||
```caddy
|
||||
localhost
|
||||
|
||||
encode zstd gzip
|
||||
encode
|
||||
templates
|
||||
file_server browse
|
||||
```
|
||||
|
@ -165,7 +165,7 @@ is equivalent to this one:
|
|||
|
||||
```caddy
|
||||
localhost {
|
||||
encode zstd gzip
|
||||
encode
|
||||
templates
|
||||
file_server browse
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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>]
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
```
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue