📚 Quick Definition

The resource has not been modified since the version specified by the If-Modified-Since or If-None-Match request headers. The server does not return a body - the client should use its cached copy. This is a critical part of HTTP caching that significantly reduces bandwidth usage.

When It Occurs

A 304 Not Modified response is returned when a client sends a conditional request (using If-None-Match or If-Modified-Since headers) and the server determines that the resource has not changed since the client last retrieved it. Instead of re-sending the entire resource, the server simply confirms the cached version is still valid.

🛠 Common Use Cases

  • Browser cache validation for CSS, JavaScript, and image files
  • CDN cache validation to reduce origin server load
  • API response caching for frequently polled endpoints
  • Conditional GET requests to check if data has been updated
  • Reducing bandwidth for large resources that rarely change
  • ETag-based cache validation for dynamic content

Best Practices

  • Implement ETag and Last-Modified headers on your server responses
  • 304 reduces bandwidth significantly - a major performance optimization
  • The 304 response must not include a response body
  • Implement conditional requests in your API clients to leverage caching
  • Combine with Cache-Control headers for a complete caching strategy
  • Browsers handle 304 automatically for static assets - no extra code needed

📡 HTTP Example

Request (conditional)
GET /style.css HTTP/1.1
Host: www.example.com
If-None-Match: "abc123"
Response
HTTP/1.1 304 Not Modified
ETag: "abc123"
Cache-Control: max-age=3600

(no body - client uses cached version)

Frequently Asked Questions

Does 304 save bandwidth? +
Yes, 304 responses save significant bandwidth because the response has no body. Instead of re-downloading the full resource, the server simply tells the client that its cached copy is still valid. This is especially impactful for large assets like images, CSS files, and JavaScript bundles that may be hundreds of kilobytes or more.
What are ETags? +
ETags (Entity Tags) are unique identifiers assigned by the server to specific versions of a resource. They act like fingerprints - when the resource changes, the ETag changes. Clients send the ETag back in an If-None-Match header on subsequent requests, and the server compares it to the current version. If they match, the server returns 304 instead of the full resource.
Should APIs use 304? +
Yes, implementing 304 responses in APIs can significantly reduce bandwidth usage and improve performance. By using ETags or Last-Modified headers, your API can skip sending large JSON payloads when the data has not changed. This is especially useful for polling endpoints, dashboard data, or any frequently accessed resources.