No Content
The server successfully fulfilled the request and that there is no additional content to send in the response payload body.
What it means
The HTTP 204 No Content success status response code indicates that a request has succeeded, but that the client doesn't need to navigate away from its current page.
A 204 response MUST NOT include a message-body, and thus is always terminated by the first empty line after the header fields.
How it works
- 1The client sends a request that modifies server state.
- 2The server successfully applies the modification.
- 3Because the client already knows the state it just sent, the server doesn't need to echo the data back.
- 4The server responds with '204 No Content' and an empty body.
Why you're seeing this
- • The operation succeeded and there is nothing to return.
How to fix it
- • Ensure your HTTP client doesn't throw a JSON parsing error trying to parse the empty body. Most modern fetch wrappers handle 204s correctly.
Framework Implementations
Express.js
app.delete('/items/:id', (req, res) => {
database.delete(req.params.id);
res.sendStatus(204);
});Real-Life Scenarios
Use this primarily for DELETE requests (where the resource is gone) or PUT/PATCH requests where the client already has the exact updated representation of the resource.
Deleting a Resource
A user clicks 'Delete Account'. The client sends a DELETE request. The server deletes the account and returns 204 No Content since there is no account data left to return.
Auto-saving a Draft
A blog editor silently auto-saves via PUT every 10 seconds. Returning 204 saves bandwidth because the client already has the exact text.
HTTP Transaction
1. Client Request
DELETE /api/v1/comments/451 HTTP/1.1 Host: api.blog.com Authorization: Bearer my-token
2. Server Response
HTTP/1.1 204 No Content Date: Tue, 04 Jul 2024 12:00:00 GMT Connection: keep-alive
SEO Implications
Googlebot handles 204 responses by retaining the existing crawled content, but usually, 204s are the result of API calls, not page loads.