This page is about Caddy 1 and will go away soon because Caddy 2 is now available. Click here for Caddy 2.

User Guide

http.gzip

gzip enables gzip compression if the client supports it. By default, responses are not gzipped. If enabled, the default settings will ensure that images, videos, and archives (already compressed) are not gzipped.

Note that, even without the gzip directive, Caddy will serve .gz (gzip) or .br (brotli) compressed files if they already exist on disk and the client supports that encoding.

Syntax

gzip

The plain gzip config is good enough for most things, but you can gain more control if needed:

gzip { ext extensions... not paths level compression_level min_length min_bytes }

Examples

Enable gzip compression:

gzip

Enable very fast but minimal compression except in the /images and /videos folders (note, however, that images and videos will not be gzipped anyway):

gzip { level 1 not /images /videos }

Need help with this feature?

Join us in the Caddy forum, where the open source community gathers to share their knowledge.

Does your company use Caddy?

Purchase a commercial license to use Caddy with your business and for basic email support, along with other benefits!