304 Not Modified
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
What Visitors Should Do
- Browser uses cached version
Notes for Developers
- Implement ETag and Last-Modified headers
- Support conditional requests
How Conditional Requests Produce a 304
A 304 is the server's answer to a conditional GET or HEAD. The browser stores a validator from the first response and sends it back next time:
ETagin the response, returned asIf-None-Matchin the next requestLast-Modifiedin the response, returned asIf-Modified-Since
If the resource has not changed, the server answers 304 Not Modified with no body, and the browser uses its cached copy. You can test it yourself:
curl -I https://example.com/style.css # note the ETag value
curl -I -H 'If-None-Match: "abc123"' https://example.com/style.cssIf a page keeps showing outdated content, the server is probably returning 304 because its ETag or Last-Modified value did not change after a deploy. Version your asset URLs (for example main.css?v=2) or purge the cache.
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 9110 Section 15.4.5.