HTTPError.net

The fastest way to diagnose, understand, and fix any HTTP status code

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

What Visitors Should Do

Notes for Developers

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:

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.css

If 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.

View the IANA HTTP Status Code Registry →