304

Not Modified

3xx Redirection

ELI5

You already have the latest version! The thing you're asking for hasn't changed since you last got it.

Server perspective

Use 304 for conditional GET or HEAD requests when the client's cached representation is still current.

When to use

  • Return 304 when If-None-Match or If-Modified-Since validates successfully
  • Use it to save bandwidth for unchanged cacheable resources
  • Conditional GET requests with If-None-Match
  • Conditional GET requests with If-Modified-Since
  • Conditional HEAD requests using validators

How to respond

  • Do not include a response body
  • Include the headers that would accompany a 200 response for the same resource — at minimum Date, ETag, Cache-Control, Expires, Vary, and Content-Location when applicable

Headers to consider

  • Date
  • ETag
  • Last-Modified
  • Cache-Control
  • Expires
  • Vary
  • Content-Location

Response body

  • Do not include a response body in a 304 response.

Server-side pitfalls

  • Do not return 304 for unconditional requests
  • Return 200 with the representation when the resource changed
  • For unconditional requests (use 200 OK)
  • When content has actually changed (use 200 OK)
  • For non-GET/HEAD methods

Examples

Cached resource validation

Request:GET https://api.example.test/api/data # Headers If-None-Match: "abc123"
Response:304 Not Modified # Headers ETag: "abc123"

Client's cached version with ETag "abc123" is still current

References

Related Status Codes