Response code 304?

1. Caddy version (caddy version):

(devel)

2. How I run Caddy:

./caddy start

a. System environment:

MacOS 10.14.6

b. Command:

./caddy start

paste command here

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

http://127.0.0.1:4000, http://localhost:4000 {
    root * /Users/joe/caddy/public_html
    log {
        output file http.log
        format logfmt
    }
    file_server
    templates
}


3. The problem I’m having:

I notice the log shows status returned is either 200 or 304.
304 is consistent on the pages that return it.

4. Error messages and/or full log output:

2020/05/11 02:32:04.805 INFO http.log.access.log0 handled request {“request”: {“method”: “GET”, “uri”: “/assets/home1.css”, “proto”: “HTTP/1.1”, “remote_addr”: “127.0.0.1:65151”, “host”: “127.0.0.1:4000”, “headers”: {“Cookie”: ["_ga=GA1.1.1753940845.1588802039; _gid=GA1.1.883587341.1589153575; _vianet2_session=elJjVTlNaTlZeTBuQldkSTEzNno1NURJemJVM1JBMS85SnZqZHErbkdVUWRmNFNTVjZjelpjTUpTWjBobVZnWVF1aFR3WHVpQ2dFQ0hSTnc3R3h1V1htWEZXYWF2M003Qk9iTG5JSnBxbEJWQTJuWXQrM0p1V2RDQWlVcVdzZ0lPWmwva0FPQk8rbzRBQmxHVmFXYVN3PT0tLVNqL2NqSDNOaWRBZmowK0R5WmVsckE9PQ%3D%3D–2a74409d890dd848ecf9e0fcbbf2006489787bac"], “Connection”: [“keep-alive”], “If-None-Match”: ["“qa5amc1kr”"], “Accept”: [“text/css,/;q=0.1”], “If-Modified-Since”: [“Mon, 11 May 2020 02:23:00 GMT”], “User-Agent”: [“Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Safari/605.1.15”], “Referer”: [“http://127.0.0.1:4000/colo.html”], “Accept-Language”: [“en-us”], “Accept-Encoding”: [“gzip, deflate”]}}, “common_log”: “127.0.0.1 - - [10/May/2020:19:32:04 -0700] “GET /assets/home1.css HTTP/1.1” 304 0”, “latency”: 0.000098316, “size”: 0, “status”: 304, “resp_headers”: {“Etag”: ["“qa5amc1kr”"], “Server”: [“Caddy”]}}

ts=1589164324.805217 level=info msg=“handled request” requestError=“unsupported value type” common_log=“127.0.0.1 - - [10/May/2020:19:32:04 -0700] “GET /assets/home1.css HTTP/1.1” 304 0” latency=0.000098316 size=0 status=304 resp_headersError=“unsupported value type”

5. What I already tried:

6. Links to relevant resources:

From the Mozilla web docs:

The HTTP 304 Not Modified client redirection response code indicates that there is no need to retransmit the requested resources. It is an implicit redirection to a cached resource. This happens when the request method is safe, like a GET or a HEAD request, or when the request is conditional and uses a If-None-Match or a If-Modified-Since header.

The equivalent 200 OK response would have included the headers Cache-Control , Content-Location , Date , ETag , Expires , and Vary .

304 Not Modified - HTTP | MDN

Basically, when your browser re-requests the same file, it sends If-Modified-Since and Caddy’s file server can say “nope, the file hasn’t been modified since you last checked, your cached copy is still good” (this is Status 304).

2 Likes

So it’s nothing to worry about? It’s not actually an error code?

Thanks!

PS:

My server say’s it’s version is ‘(devel)’. Ever consider marking the devel versions with a date code?

1 Like

Yes, Status 3xx are not errors, they are (all?) redirections. 304 is a “redirection” to the asset your browser has already cached.

The devel versions are properly versioned (to the git commit) if you build it as a dependency, or with xcaddy.

Due to a bug in Go, these basic steps do not embed version information. If you want the version ( caddy version ), you need to compile Caddy as a dependency rather than as the main module. Instructions for this are in Caddy’s main.go file. Or, you can use xcaddy which automates this.

Build from source — Caddy Documentation

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