HTTP

HTTP 304 Not Modified vs 401 Unauthorized

HTTP 304 (Not Modified) is a 3xx Redirection response, while 401 (Unauthorized) is a 4xx Client Error response. 304 indicates that the resource has not been modified since the last request. The client can use its cached copy. In contrast, 401 means that the request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme.

Description

The resource has not been modified since the last request. The client can use its cached copy.

When You See It

When the browser cache is still valid (If-None-Match / If-Modified-Since headers match).

How to Fix

No fix needed. This saves bandwidth by confirming the cached version is still current.

Description

The request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme.

When You See It

When accessing a protected resource without credentials or with expired tokens.

How to Fix

Include valid authentication credentials (API key, Bearer token, Basic auth) in the Authorization header.

Key Differences

1.

304 is a 3xx Redirection response, while 401 is a 4xx Client Error response.

2.

HTTP 304: The resource has not been modified since the last request. The client can use its cached copy.

3.

HTTP 401: The request requires user authentication. The response includes a WWW-Authenticate header indicating the authentication scheme.

4.

You encounter 304 when when the browser cache is still valid (If-None-Match / If-Modified-Since headers match).

5.

You encounter 401 when when accessing a protected resource without credentials or with expired tokens.

When to Use Which

For 304 (Not Modified): No fix needed. This saves bandwidth by confirming the cached version is still current. For 401 (Unauthorized): Include valid authentication credentials (API key, Bearer token, Basic auth) in the Authorization header.

Learn More