From bb897a9035d65cbdb52d577f810eea59d88acc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Thu, 9 Jan 2025 15:54:47 +0100 Subject: [PATCH] docs: encode short syntax --- src/docs/markdown/caddyfile-tutorial.md | 6 +++--- src/docs/markdown/caddyfile.md | 2 +- src/docs/markdown/caddyfile/directives/encode.md | 12 +++++++++--- src/docs/markdown/caddyfile/patterns.md | 6 +++--- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/docs/markdown/caddyfile-tutorial.md b/src/docs/markdown/caddyfile-tutorial.md index 82144b7..1c2f76b 100644 --- a/src/docs/markdown/caddyfile-tutorial.md +++ b/src/docs/markdown/caddyfile-tutorial.md @@ -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 } diff --git a/src/docs/markdown/caddyfile.md b/src/docs/markdown/caddyfile.md index 26f6550..fb6f7c2 100644 --- a/src/docs/markdown/caddyfile.md +++ b/src/docs/markdown/caddyfile.md @@ -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 } diff --git a/src/docs/markdown/caddyfile/directives/encode.md b/src/docs/markdown/caddyfile/directives/encode.md index 29d283f..f63506c 100644 --- a/src/docs/markdown/caddyfile/directives/encode.md +++ b/src/docs/markdown/caddyfile/directives/encode.md @@ -22,7 +22,7 @@ Encodes responses using the configured encoding(s). A typical use for encoding i ## Syntax ```caddy-d -encode [] { +encode [] [] { # encoding formats gzip [] zstd [] @@ -36,7 +36,7 @@ encode [] { } ``` -- **<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** 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 } ``` diff --git a/src/docs/markdown/caddyfile/patterns.md b/src/docs/markdown/caddyfile/patterns.md index c4b4ebf..770dd12 100644 --- a/src/docs/markdown/caddyfile/patterns.md +++ b/src/docs/markdown/caddyfile/patterns.md @@ -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