Serve precompressed static files from caddy

Background

While Caddy can compress files as they are requested, my website is completely static (built using Zola )and all of this work can be done once ahead of time. For this purpose I use precompress.

To make everything work, Caddy needs to be instructed to look for precompressed files:

file_server {
    precompressed
}

To actually precompress, you just need to install and point precompress at the right folder. The default options work well for me.

cargo install precompress
~/.cargo/bin/precompress {{your site folder}}

I use a justfile to manage building and deploying my website, which lets me do everything in a one-liner:

build:
    rm -rf public
    ~/.cargo/bin/zola build
    ~/.cargo/bin/precompress public

install-deps:
    cargo install --locked --git https://github.com/getzola/zola
    cargo install precompress

deploy-victorsavu: build
    rsync -rzP --delete public/ victorsavu@victorsavu.eu:victorsavu/

2026-03-07