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
Common Cause
Browser sending If-Modified-Since with a cached timestamp
Common Cause
Client sending If-None-Match with a stored ETag value
Common Cause
CDN checking origin server for content changes
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)
})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:
301 301 Moved Permanently
The requested resource has been permanently moved to a new URL.
302 302 Found (Temporary Redirect)
The requested resource is temporarily located at a different URL.
307 307 Temporary Redirect
The resource is temporarily at a different URL — preserve the HTTP method.
308 308 Permanent Redirect
The resource has been permanently moved — preserve the HTTP method.
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.