post(precompressed): new option in caddy v2.4.0

This commit is contained in:
Ming Di Leom 2022-05-06 06:35:12 +00:00
parent ca70fc857b
commit 10bd0dae27
No known key found for this signature in database
GPG Key ID: 32D3E28E96A695E8
1 changed files with 3 additions and 0 deletions

View File

@ -2,10 +2,13 @@
title: Serving pre-compressed files in Caddy 2
excerpt: gzip and brotli files
date: 2020-11-12
updated: 2022-05-06
tags:
- caddy
---
> Caddy [v2.4.0](https://github.com/caddyserver/caddy/releases/tag/v2.4.0-beta.2) added a new option [`precompressed`](https://caddyserver.com/docs/caddyfile/directives/file_server) to support serving pre-compressed assets.
Caddy v0.9.4+ and v1.0.0+ support pre-compressed gzip and brotli files automatically. However, this feature is [not yet](https://github.com/caddyserver/caddy/issues/2665) implemented in v2 and requires manual configuration. Examples available at the Caddy forum are incomplete, it's either gzip or brotli. The config provided in this guide supports _both_, prioritising brotli if supported by the requesting web browser (and there are .br files), otherwise fallback to gzip.
## Default usage