The HTTP 304 status code stands for "Not Modified". It is a redirection response indicating that the requested resource has not changed since the last time the client requested it, so the client should use the cached version instead of downloading it again.
When is HTTP 304 Used?
- Used for browser caching to improve performance by avoiding unnecessary data transfers.
- When a client sends a request with an If-Modified-Since or If-None-Match header to check if a resource has been updated.
- Helps reduce server load and bandwidth usage.
Example Scenarios
- Web Page Caching – A browser loads an image from the cache instead of downloading it again.
- API Caching – An API response is stored, and only new data is fetched if it has changed.
- CDN Optimization – Content Delivery Networks (CDNs) use 304 to serve cached files efficiently.
Example
Client Request (Checking If a Resource Is Updated)
GET /image.png HTTP/1.1
Host: example.com
If-Modified-Since: Wed, 10 Feb 2025 12:00:00 GMT
Server Response (Resource Not Modified, Use Cached Version)
HTTP/1.1 304 Not Modified
Summary
HTTP 304 means the requested resource has not changed, and the client should use the cached version instead of re-downloading it. It is commonly used for browser caching, API efficiency, and CDN optimizations.