← Back to Chapters

HTTP 304 — Not Modified

? HTTP 304 — Not Modified

? Quick Overview

The 304 Not Modified status code tells the client that the requested resource has not changed since the last request. Instead of sending the full response again, the server instructs the browser to use its cached version.

? Key Concepts

  • Used with browser caching mechanisms
  • Reduces bandwidth and improves performance
  • No response body is sent
  • Works with headers like ETag and If-Modified-Since

? Syntax / Theory

When a browser requests a resource, it may include cache validation headers. If the server determines that the resource is unchanged, it responds with 304 Not Modified.

? Code Example(s)

? View Code Example
// Example of an HTTP response with 304 status
HTTP/1.1 304 Not Modified
Date: Tue, 03 Jan 2026 10:30:00 GMT
ETag: "abc123"
? View Code Example
// Browser request using cache validation headers
GET /style.css HTTP/1.1
Host: example.com
If-None-Match: "abc123"

? Live Output / Explanation

What Happens?

Since the ETag sent by the browser matches the server version, the server replies with 304 Not Modified. The browser loads the file from its cache instead of downloading it again.

? Interactive Example

Use the simulator below to understand how ETag validation results in a 200 or 304 response.

?️ Browser (Client) Cached ETag: None
 
☁️ Server Current ETag: "v1"
Click "Request Resource" to start...
? View Fetch Implementation
// JavaScript fetch request that may result in 304
fetch("/data.json")
.then(res => {
  if (res.status === 304) {
    console.log("Not modified, using cache.");
  } else {
    console.log("Downloaded new content.");
  }
});

? Use Cases

  • Optimizing website load performance
  • Reducing server bandwidth usage
  • Efficient delivery of static assets
  • Improving user experience on repeat visits

✅ Tips & Best Practices

  • Always configure proper cache headers
  • Use ETag or Last-Modified consistently
  • Do not send a response body with 304
  • Test caching behavior in browser dev tools

? Try It Yourself

  • Inspect network requests on a real website
  • Disable cache and compare responses
  • Modify a file and observe status changes
  • Implement caching headers on a local server