More
More
204 No Content
The request succeeded and there is deliberately no body.
- Code
204- Reason phrase
- No Content
- Class
- 2xx Success
- Defined in
- RFC 9110 section 15.3.5
- Cacheable by default
- Yes
What it means
Success: the request was received, understood and accepted.
When a server should send it. When the action succeeded and there is nothing to send back: a DELETE, a saved setting, an autosave or a beacon. A 204 must not have a body; anything after the headers is ignored or breaks the connection.
Common causes. A DELETE, a saved form with nothing to show, or an analytics beacon.
What to do. Nothing. Do not try to parse a body; there is none.
How clients and crawlers treat it
Browsers and HTTP clients. Browsers stay on the current page when a link or form gets a 204, which is why it suits background actions. fetch() gives an empty body, so calling response.json() on it throws.
Google Search. Google gets no content to index; Search Console may report the URL as a soft 404. Source: Google Search Central, How HTTP status codes, and network and DNS errors affect Google Search.
Caching. Cacheable by default (RFC 9110 section 15.1). With no Cache-Control or Expires header, a cache may still store it and reuse it for a heuristic period, often 10% of the time since Last-Modified, so set Cache-Control explicitly if that is not what you want.
Example response
HTTP/1.1 204 No Content (no body)
How to send 204
location /example {
return 204;
}
http_response_code(204); exit;
res.writeHead(204); res.end();
# in a view function return '', 204
Change the paths to suit. In nginx, add_header needs always to apply to error responses.
Related codes
- 200OKThe request succeeded and the response carries the result.
- 205Reset ContentThe request succeeded and the client should reset the form or view that sent it.
- 202AcceptedThe request was accepted for processing, but the work is not finished yet.
All status codes · All 2xx codes
Names and numbers from the IANA HTTP Status Code Registry. Google Search behaviour as documented by Google Search Central.