docs: precompressed short syntax (#446)

This commit is contained in:
Kévin Dunglas 2025-01-09 17:49:12 +01:00 committed by GitHub
parent 8c83f56f3f
commit ef31c7646a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View file

@ -38,7 +38,7 @@ file_server [<matcher>] [browse] {
browse [<template_file>] { browse [<template_file>] {
reveal_symlinks reveal_symlinks
} }
precompressed <formats...> precompressed [<formats...>]
status <status> status <status>
disable_canonical_uris disable_canonical_uris
pass_thru pass_thru
@ -64,7 +64,7 @@ file_server [<matcher>] [browse] {
- **sort** <span id="sort"/> changes the default sort for directory listings. The first parameter is the field/column to sort by: `name`, `namedirfirst`, `size`, or `time`. The second argument is an optional direction: `asc` or `desc`. For example, `sort name desc` will sort by name in descending order. - **sort** <span id="sort"/> changes the default sort for directory listings. The first parameter is the field/column to sort by: `name`, `namedirfirst`, `size`, or `time`. The second argument is an optional direction: `asc` or `desc`. For example, `sort name desc` will sort by name in descending order.
- **precompressed** <span id="precompressed"/> is the list of encoding formats to search for precompressed sidecar files. Arguments are an ordered list of encoding formats to search for precompressed [sidecar files](https://en.wikipedia.org/wiki/Sidecar_file). Supported formats are `gzip` (`.gz`), `zstd` (`.zst`) and `br` (`.br`). - **precompressed** <span id="precompressed"/> is the list of encoding formats to search for precompressed sidecar files. Arguments are an ordered list of encoding formats to search for precompressed [sidecar files](https://en.wikipedia.org/wiki/Sidecar_file). Supported formats are `gzip` (`.gz`), `zstd` (`.zst`) and `br` (`.br`). If formats are ommited, they default to `br zstd gzip` (in that order).
All file lookups will look for the existence of the uncompressed file first. Once found Caddy will look for sidecar files with the file extension of each enabled format. If a precompressed sidecar file is found, Caddy will respond with the precompressed file, with the `Content-Encoding` response header set appropriately. Otherwise, Caddy will respond with the uncompressed file as normal. If the [`encode` directive](encode) is enabled, then it may compress the response on-the-fly if not precompressed. All file lookups will look for the existence of the uncompressed file first. Once found Caddy will look for sidecar files with the file extension of each enabled format. If a precompressed sidecar file is found, Caddy will respond with the precompressed file, with the `Content-Encoding` response header set appropriately. Otherwise, Caddy will respond with the uncompressed file as normal. If the [`encode` directive](encode) is enabled, then it may compress the response on-the-fly if not precompressed.
@ -119,10 +119,10 @@ file_server {
} }
``` ```
If supported by the client (`Accept-Encoding` header) checks the existence of precompressed files along side the requested file. So if `/path/to/file` is requested, it checks for `/path/to/file.zst`, `/path/to/file.br` and `/path/to/file.gz` in that order and serves the first available file with corresponding Content-Encoding: If supported by the client (`Accept-Encoding` header) checks the existence of precompressed files along side the requested file. So if `/path/to/file` is requested, it checks for `/path/to/file.br`, `/path/to/file.zst` and `/path/to/file.gz` in that order and serves the first available file with corresponding `Content-Encoding`:
```caddy-d ```caddy-d
file_server { file_server {
precompressed zstd br gzip precompressed
} }
``` ```

View file

@ -1515,9 +1515,9 @@
If your deployment pipeline compresses site resources, Caddy can automatically detect them and serve them in their "precompressed" encoding for higher efficiency and greater throughput. If your deployment pipeline compresses site resources, Caddy can automatically detect them and serve them in their "precompressed" encoding for higher efficiency and greater throughput.
</div> </div>
<ul class="detail"> <ul class="detail">
<li>Gzip</li>
<li>Brotli</li> <li>Brotli</li>
<li>Zstandard</li> <li>Zstandard</li>
<li>Gzip</li>
</ul> </ul>
</div> </div>
<div class="feature-row"> <div class="feature-row">

View file

@ -38,7 +38,7 @@ root * /var/www
# Serve precompressed files if present # Serve precompressed files if present
file_server /downloads/* { file_server /downloads/* {
precompressed gzip zstd br precompressed
} }
# Compress everything else that would benefit # Compress everything else that would benefit