Example HTTP Response
HTTP/1.1 304 Not Modified
ETag: "abc123"- Browser cache is still valid
- Resource hasn't changed since If-Modified-Since
- ETag matches, no download needed
What does this mean?
Same old, same old! Nothing has changed since you last checked. Use your cached copy!
Technical Definition
Indicates that the resource has not been modified since the version specified in the request headers.
RFC Says
"The 304 (Not Modified) status code indicates that a conditional GET or HEAD request has been received and would have resulted in a 200 (OK) response if it were not for the fact that the condition evaluated to false."
Plain English:
The resource hasn't changed since your last request, so use your cached version. This is used with conditional requests (If-Modified-Since or If-None-Match headers) to save bandwidth. The response should not contain a message body.
Common Misinterpretation
304 is not an error - it's a successful response indicating the cache is still valid. Always return appropriate cache headers (ETag or Last-Modified) with the 304 so the client can validate the cache again in the future.
Ready-to-use code for returning this HTTP status in your application:
// Express.js
app.get('/example', (req, res) => {
res.status(304).json({
error: 'Not Modified',
message: 'Your error message here'
});
});
// Native HTTP
const http = require('http');
http.createServer((req, res) => {
res.writeHead(304, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
error: 'Not Modified',
message: 'Your error message here'
}));
}).listen(3000);