304 vs 204: Not Modified vs No Content
304 and 204 can look similar in logs, but they tell clients, crawlers, and API consumers different things.
| Aspect | HTTP 304 โ Not Modified | HTTP 204 โ No Content |
|---|---|---|
| Definition | Issued in response to a conditional GET (If-None-Match or If-Modified-Since). The server confirms the cached version is still valid, saving bandwidth by not resending the body. | Commonly used for DELETE operations, form submissions, or PUT updates where no body is needed in the response. The client should not navigate away or reload. |
| Plain-language summary | The resource has not changed since the version the client already has cached. The server sends no body โ the client uses its cached copy. This is the conditional request success response, triggered by If-None-Match or If-Modified-Since request headers. | HTTP 204 No Content indicates the request succeeded but there is no content to return. |
| When to use | You do not "choose" to return 304 โ it is issued automatically when the server honors a conditional GET. Implement 304 support by: setting ETag or Last-Modified headers on cacheable resources, validating the If-None-Match / If-Modified-Since headers in your server handler, and returning 304 (no body) when the resource is unchanged. | HTTP 204 No Content indicates the request succeeded but there is no content to return. |
| Client behavior | Client uses its cached copy of the resource. No new body is received. The response may include updated header fields (e.g., Cache-Control, Expires) to refresh the cache metadata. Browsers update cache freshness information and render the cached version. | Client handles 204 according to success semantics. |
| Caching behavior | The core of HTTP conditional caching. Saves bandwidth by confirming the cached version is still valid. Works with ETags (content hash) or Last-Modified timestamps. Proxies and CDNs also honor these and may serve 304s from their own caches without hitting the origin. | See 204 caching spec. |
| SEO / crawler impact | Search crawlers interpret 304 (redirect-codes) for indexation and link equity accordingly. | Search crawlers interpret 204 (success) for indexation and link equity accordingly. |
| API / backend impact | API clients branching on 304 expect Not Modified semantics. | API clients branching on 204 expect No Content semantics. |
| Safe to retry? | Follow redirect, then retry original intent | Only after fixing the underlying cause |
Common real-world scenarios
When you see HTTP 304
High 304 rates on static assets (JS, CSS, images) are healthy and expected โ this is efficient caching working correctly. Unexpected 304s on API endpoints that should always return fresh data indicate ETag generation is too conservative. Watch for: 304s on endpoints where the client always expects fresh data, and missing 304 support on cacheable static assets (wastes bandwidth).
When you see HTTP 204
204 appears in production when: Normal protocol behavior.
Decision rule
Use 304 when the response should communicate not modified behavior; use 204 when no content is the accurate protocol signal.
A frequent mistake is swapping 304 and 204 for convenience; that causes client retry bugs, incorrect cache signals, and misleading monitoring data.
Use 304 when the correct protocol signal is Not Modified. Use 204 when the correct signal is No Content. Returning either code for the wrong reason breaks client expectations, cache behavior, and monitoring accuracy.
FAQ
What is the biggest difference between 304 and 204?
304 communicates Not Modified, while 204 communicates No Content. Choosing the right one keeps clients and intermediaries predictable.
Do 304 and 204 have SEO or caching impact?
Yes. Search engines and caches interpret status classes differently. Use each code according to its semantics to avoid accidental indexing, stale responses, or crawl inefficiency.
Can APIs safely return 304 instead of 204?
Only when it matches contract semantics. API clients often branch logic by exact code, so swapping them can break retries, auth handling, or user-facing errors.
Full guides
HTTP 304 Not Modified โ full guide ยท HTTP 204 No Content โ full guide ยท All comparisons ยท HTTP 304 status reference ยท HTTP 204 status reference