Does Caddy have some sort of local cache?

Apologies for deleting the template. It is difficult for me to word my question using the template.

I have experienced many times now when developing my caddy configurations that sometimes my changes simply don’t get reflected when I restart the server to pick up my Caddyfile changes.

For example, I had a Caddyfile like this:

localhost {
  reverse_proxy https://www.somewhere.com
}

And I ran it many times. A few days later I wanted to add another directive in there:

localhost {
  reverse_proxy https://www.somewhere.com
  respond /specific/path "hello"
}

Then:

  1. CTRL-C to stop my Caddy server.
  2. caddy run to start it again.
  3. Visit localhost/specific/path in my browser, expect to see “hello”. Instead I see the reverse_proxy to “https://www.somewhere.com

I think I’m going crazy for half an hour, and then I decide to re-create this exact same Caddyfile in a different directory, and caddy run from there. Visit localhost/specific/path and voila, I get “hello”!

So my question is: Does Caddy have some sort of cache where it remembers the directives and their results or something? If so, is there a way to clear it?

My caddy version is v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=

I don’t think it’s a browser cache issue because I even opened up Safari which I have never used to visit localhost, and I still see the Caddyfile result.

I also checked the response using curl, and it’s giving me a stale information that doesn’t even exist in curl localhost:2019/config/ anymore!

There are caching modules available for content, but no, Caddy doesn’t cache this kind of thing. It does autosave the current running configuration (for example if you modify it via the API), but it only resumes that if you specify the --resume flag.

You could try caddy reload --config ./Caddyfile or something like that to tell Caddy more specifically, hey, I want you to load this new config right here (to eliminate it maybe finding another config in a default location, perhaps?).

Never hurts to pgrep caddy after killing it to be super sure there’s not a second one running on the old config, still, too.

2 Likes

ooooh pgrep caddy resulted in two ids.

1 Like

You didn’t fill out the help topic template, so we don’t know how you installed or ran Caddy. That’s precisely the information we need to help, and why the template is mandatory as part of the forum rules.

1 Like

@francislavoie That’s OK. @Whitestrake already gave me the solution. The answer was to pgrep caddy to see if other caddy instances were running.

That doesn’t really answer the fundamental reason that went wrong. You shouldn’t be running Caddy directly if you installed Caddy as a systemd service for example. But I have to make an assumption with that because you didn’t say how you installed Caddy. We could help you by explaining what you did wrong, but we can only do that if you give us the requisite context.

1 Like

I installed caddy using Homebrew.

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