304 Not Modified
Fault: Neither
TL;DR
Use cached version of the resource.
The resource has not been modified since the last request.
What HTTP 304 Not Modified Means
The resource has not been modified since the last request.
Use cached version of the resource.
Common Causes
- If-Modified-Since conditional request
- ETag validation
- Resource unchanged
How to Fix It (For Visitors)
- Browser uses cached version
How to Fix It (For Developers/Admins)
- Implement ETag and Last-Modified headers
- Support conditional requests
Returning a 304 Not Modified (Code Examples)
If you build APIs or web apps, here is how to send an HTTP 304 response and how to test for it:
Node.js (Express)
app.get('/resource', (req, res) => {
res.status(304).json({ error: 'Not Modified' });
});
Python (Flask)
@app.route('/resource')
def resource():
return jsonify(error='Not Modified'), 304
PHP
<?php
http_response_code(304);
header('Content-Type: application/json');
echo json_encode(['error' => 'Not Modified']);
Check the status with curl
curl -I https://example.com/resource
# Look for: HTTP/1.1 304 Not Modified
Frequently Asked Questions
What does HTTP 304 Not Modified mean?
Use cached version of the resource. In short: The resource has not been modified since the last request.
How should I handle an HTTP 304 Not Modified response?
Implement ETag and Last-Modified headers. Support conditional requests.
Official Specification
The 304 Not Modified status code is defined in RFC 7232 Section 4.1.