The respond directive and the close keyword

1. Caddy version (caddy version):

# caddy version
v2.4.3 h1:Y1FaV2N4WO3rBqxSYA8UZsZTQdN+PwcoOcAiZTM8C0I=

2. How I run Caddy:


a. System environment:


b. Command:


c. Service/unit/compose file:


d. My complete Caddyfile or JSON config:

Code extract

    # External access denied to these files.
    @forbidden {
        not path /wp-includes/ms-files.php
        path /wp-admin/includes*
        path /wp-includes*
        path /wp-config.php
    respond @forbidden "Access denied" 403 {

3. The problem I’m having:

The documentation for respond states the following:

  • close will close the client’s connection to the server after writing the response.

Whether I use the close keyword or not with the respond directive, there’s no visible difference in a browser…


…so, I’m a little unclear on what the close keyword actually does?

4. Error messages and/or full log output:


5. What I already tried:

Refer to point 3.

6. Links to relevant resources:

  1. respond

It’s generally not that useful. Closing the connection just means that subsequent requests will require a new TCP connection. It’s a bit more of a “go away now” after writing a response.

1 Like

It is useful sometimes. You might not want to keep a resource around for a client that you don’t particularly need to be serving. We use it for our auto http → https redirects. No point in leaving that connection open on port 80.


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