HTTP Status Codes

304 304 Not Modified

The resource has not been modified since the last request, use the cached version.

What Is This?

The HTTP 304 Not Modified status code indicates that the resource has not been modified since the last request. It is a response to conditional GET requests using headers like If-Modified-Since or If-None-Match (ETag). The response must not include a body — the client should use its cached version. This reduces bandwidth and improves performance.

Common Causes & Solutions

1

Common Cause

Browser sending If-Modified-Since with a cached timestamp

2

Common Cause

Client sending If-None-Match with a stored ETag value

3

Common Cause

CDN checking origin server for content changes

4

Implement ETag support

Generate strong ETags based on content hash to enable efficient conditional requests.

// Node.js (Express) with ETag and conditional requests
app.get('/api/data', (req, res) => {
  const data = fetchData()
  const etag = crypto.createHash('md5').update(JSON.stringify(data)).digest('hex')
  
  if (req.headers['if-none-match'] === etag) {
    return res.status(304).end()
  }
  
  res.set('ETag', etag)
  res.json(data)
})
5

Configure caching headers

Set appropriate Cache-Control and Last-Modified headers to enable browser caching and reduce server load.

Cache-Control: public, max-age=3600, must-revalidate
Last-Modified: Wed, 21 Oct 2024 07:28:00 GMT
ETag: "33a64df551425fcc55e4d42a148795d9f25f89d4"

Related Entries

More from this reference:

Frequently Asked Questions

Does 304 count as a request in analytics?

Yes. 304 responses are still HTTP requests and are counted in server logs and analytics. However, since the response has no body, bandwidth usage is minimal.

How does 304 differ from 200 with cached content?

With 200, the server sends the full response body. With 304, the server sends only headers — the client uses its locally cached copy. This significantly reduces bandwidth for unchanged resources.