A 304 response from a web server means that the browser can use its cached version of the response to the request that was sent.

This works by comparing the hash of the content of the response body, which the browser receives as an ETag header on the initial response (the one with the content). On subsequent requests, and if the browser determines that the cached response hasn't expired (see the Cache-Control response header), it sends this hash value to the server so that it, after generating the response, can determine that it's the same that the browser has, and simply return a 304 response with no body.

In Go, this can be accomplished with a relatively simple middleware, that in its 86 lines of code perhaps illustrates what is going on better than I can here.

Latest on HTTP
Mastodon Mastodon