Restarting after updates to contents of root

Is there a best practice when updating files under the root document directory? Use case is that all files under root are generated and at times some may be removed.

When content has to be generated, I’m thinking of generating them in a new directory first, e.g. Then, renaming the current “html” to “html.old”, “” to “html” and restarting caddy with a USR1.


Hey Steve, what is the context of your question? For plain serving static files, you don’t need to reload Caddy when the files change.

1 Like

Hi Matt,

Yes, this is just serving static files.

The background is that I have the equivalent of hugo but for html-based music players. There can be a lot of churn in files generated, so it’s easier for the tool to generate all new content rather than determining the changes each time. That’s why I’m asking about rotating directories underneath Caddy. From what I read, Caddy reads files for every request, so it doesn’t matter to Caddy. But rotating directories vastly simplifies the tool that i wrote.

Caddy shouldn’t have any issues with you swapping the directories out from under it.

You could even move/delete the entire web root, and Caddy will happily carry on, handing out 404s in the meantime until you put a new folder where it expects the web root to be. No need for reloads :slight_smile:

Thank you. Nothing to worry about, just switch out the directory.