Help - build caddy with plugins, step by step

can anyone help me?
i would like to test the cache-handler plugin
but I’m having trouble installing this modul to the caddy
My steps:

  1. fresh server ubuntu 22
  2. install go and xcaddy
    sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
    curl -1sLf ‘’ | sudo gpg --dearmor -o /usr/share/keyrings/caddy-xcaddy-archive-keyring.gpg
    curl -1sLf ‘’ | sudo tee /etc/apt/sources.list.d/caddy-xcaddy.list
    sudo apt update
    sudo apt install xcaddy
  3. install module with xcaddy
    xcaddy build --with GitHub - caddyserver/cache-handler: Distributed HTTP caching module for Caddy

After these operations Caddy is not installed. What am I doing wrong?
Can anyone write a step by step guide on how to do this?
thanks for your help

1 Like

Hi @Adam_Makowski, welcome to the Caddy community!

Per, you already have followed the step by step guide.

What was the output of step 3?

I did a server reset and installed caddy again. and then used the add-package command

caddy add-package

caddy list-modules show cache handler, I think is good

Non-standard modules: 2

Unknown modules: 0

root@new-york-caddy-cache:~# caddy reload --config /etc/caddy/Caddyfile
2022/09/16 15:08:15.458 INFO using provided configuration {“config_file”: “/etc/caddy/Caddyfile”, “config_adapter”: “”}
reload: adapting config using caddyfile: /etc/caddy/Caddyfile:11: unrecognized directive: ttl

My Caddyfile

cache {
	ttl 300s
domain {
	root * /var/www/domain
	encode zstd gzip
	header Cache-Control public max-age=86400
	file_server {
		precompressed zstd br gzip

unrecognized directive: ttl ? why does it receive such a message?

I’ve edited your post really quickly just to put the Caddyfile you posted in code fences! (Triple backticks before and after, ```.) This really helps readability as it preserves mono spacing and indentation.

Because you have configured the literal site address cache with a directive of ttl inside it, which is not valid configuration. Refer back to the Caddyfile documentation, emphasis mine:

A Caddyfile consists of at least one or more site blocks, which always starts with one or more addresses for the site. Any directives appearing before the address will be confusing to the parser.

The cache handler must be placed within the site block itself, e.g. {
  cache {
    ttl 300s
  # Other site config...

This topic was automatically closed after 30 days. New replies are no longer allowed.