HTTP 304 Not Modified vs 502 Bad Gateway
HTTP 304 (Not Modified) is a 3xx Redirection response, while 502 (Bad Gateway) is a 5xx Server Error response. 304 indicates that the resource has not been modified since the last request. The client can use its cached copy. In contrast, 502 means that the server, acting as a gateway or proxy, received an invalid response from the upstream server.
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 server, acting as a gateway or proxy, received an invalid response from the upstream server.
When You See It
When Nginx/Apache can't reach the application server (e.g., Gunicorn is down, upstream timeout).
How to Fix
Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts.
Key Differences
304 is a 3xx Redirection response, while 502 is a 5xx Server Error response.
HTTP 304: The resource has not been modified since the last request. The client can use its cached copy.
HTTP 502: The server, acting as a gateway or proxy, received an invalid response from the upstream server.
You encounter 304 when when the browser cache is still valid (If-None-Match / If-Modified-Since headers match).
You encounter 502 when when Nginx/Apache can't reach the application server (e.g., Gunicorn is down, upstream timeout).
When to Use Which
For 304 (Not Modified): No fix needed. This saves bandwidth by confirming the cached version is still current. For 502 (Bad Gateway): Check if the upstream server is running. Verify proxy configuration. Check for upstream timeouts.