Knowledge Guide
HomeSystem DesignScalable Systems (Advanced Topics)

What are HTTP Conditional Requests ETag, If‑None‑Match, Last‑Modified and How They Reduce Load

HTTP conditional requests are special HTTP requests that use headers (like ETag or Last-Modified) to check if a cached resource has changed, so unchanged content isn’t re-downloaded, reducing server load and saving bandwidth.

What Are HTTP Conditional Requests?

In web caching, a conditional request means the client (e.g. your browser) asks the server only to send a resource if certain conditions are met, typically, if the content has changed since the last time it was seen.

The client includes validator headers (such as an ETag or a date) with its request.

The server then compares these validators to the current version of the resource.

If nothing has changed, the server replies with a short “Not Modified” (HTTP 304) status and no response body, meaning the client can safely use its cached copy.

If the resource has changed, the server will send the full content (HTTP 200 OK) as usual, along with updated validators for next time.

This mechanism is built into HTTP and is key to efficient web performance.

ETag and Last-Modified are the two most common validators used in conditional requests:

When a client caches a resource, it will store these validators.

Later, the client can make a conditional GET request with headers like If-None-Match (using the ETag value) or If-Modified-Since (using the last modified date).

These headers essentially mean “give me the resource only if it doesn’t match what I already have”.

Here are key differences between ETag and Last-Modified:

FeatureETagLast-Modified
DefinitionA unique identifier (string or hash) assigned by the server to represent a specific version of a resource.A timestamp indicating when the resource was last changed on the server.
Header Used For ValidationIf-None-Match (for GET) and If-Match (for PUT/DELETE).If-Modified-Since (for GET) and If-Unmodified-Since (for PUT/DELETE).
Type of ComparisonExact match of the identifier (strong or weak validation).Date/time comparison.
PrecisionVery precise — can detect even small or fast changes that happen multiple times per second.Limited precision (usually 1 second) — may miss rapid updates.
Server ControlFully controlled by the server; can be based on hash, checksum, version number, etc.Based on system clock — depends on file timestamp or last modification time.
Best ForDynamic content where changes aren’t always time-based or predictable.Static content like images or files where modification time is enough.
Cache ValidationPreferred for fine-grained cache validation (especially with CDNs or APIs).Simpler validation for basic HTTP caching.
OverheadSlightly higher (server must generate and manage ETags).Low (timestamp comes from filesystem).
Common HeadersETag, If-None-Match, If-Match.Last-Modified, If-Modified-Since, If-Unmodified-Since.

How Do ETag and If-None-Match Work?

ETag: A Resource’s Fingerprint

An ETag (or entity tag) is an identifier that the server attaches to a resource to represent its current state or version. It could be a hash of the file contents or a revision number.

Every time the resource changes, a new ETag is generated by the server.

For example, an image or JSON response might come with a header ETag: "abc123", which is a unique code for that version of the content.

If-None-Match: Validating by ETag

If-None-Match is the request header the client uses to make the GET request conditional based on an ETag.

The client sends If-None-Match: "abc123" (using the ETag it saved).

This header tells the server: “Send me the resource only if its current ETag does not match abc123. In other words, “I have version abc123; give me a new copy only if there’s a different version.”

On the server side, the logic is: compare the client’s ETag with the latest ETag of the resource.

If they are the same, it means the resource has not changed, so the server responds with 304 Not Modified and no message body.

The server does not resend the content data, saving bandwidth.

If the ETag is different (meaning the resource has changed), the server will send the full resource with a normal 200 OK response and include the new ETag in the headers.

Why ETag?

ETags are very precise validators (they can detect even minor changes in content) and are ideal for cache validation.

By using ETag/If-None-Match, web servers avoid resending full responses if the content hasn’t changed, making caching more efficient and saving significant bandwidth.

ETags also have uses in preventing simultaneous update conflicts, but their primary use in this context is cache validation.

How Do Last-Modified and If-Modified-Since Work?

Last-Modified: A Resource’s Timestamp

Last-Modified is a timestamp indicating when the server believes the resource was last changed.

For example, a response might include Last-Modified: Tue, 15 Sep 2025 11:00:00 GMT. This date serves as a record of the resource’s update time.

If-Modified-Since: Validating by Date

If-Modified-Since is the request header where the client sends the last known modification date (from its cache).

For instance, If-Modified-Since: Tue, 15 Sep 2025 11:00:00 GMT tells the server: “Only send me the resource if it has been modified after September 15, 2025, 11:00:00 GMT.” The server will compare this date to the resource’s current last modified date.

If no changes have occurred after that time, the server replies with 304 Not Modified (meaning the cached copy is still good).

If there were changes after that date, the server responds with a fresh 200 OK and the updated content (plus a new Last-Modified date and possibly a new ETag).

Comparing ETag vs Last-Modified: Both serve the same general purpose of validation, but ETag is typically more accurate.

Last-Modified is a “weak validator” in the sense that it only has one-second precision and might not change if a file is modified multiple times within a second or if a server’s clock is off.

It also can’t detect changes if the file content remains the same but is rewritten. ETag, being content-based, can detect changes more reliably (byte-for-byte if a strong ETag).

However, not all servers or resources generate ETags, so Last-Modified is a good fallback mechanism and is widely used.

In practice, browsers often send both If-None-Match and If-Modified-Since together, and the server will use one or both validators to decide the response.

Check out HTTP/2 vs HTTP/1.1.

How Conditional Requests Reduce Load

HTTP conditional requests play a huge role in reducing load on networks and servers.

By avoiding sending data that the client already has, they make web communication much more efficient.

Here are the key ways conditional requests help:

It’s often said in web performance circles that “the fastest request is one that never has to be made, and the second fastest is one with no response body.”

In practice, conditional requests achieve the latter. The server’s 304 response contains no body, so the client just uses its local cache.

This makes the web application feel faster and lightens the load on servers.

Example Scenario: Conditional Request in Action

Let’s walk through a typical sequence using both ETag and Last-Modified validators:

  1. Initial Request: The browser requests a resource (for example, GET /styles.css) for the first time. The server responds with a 200 OK and the full content of the resource. Along with the content, the server sends validation headers, e.g. ETag: "abc123" and Last-Modified: Tue, 15 Sep 2025 11:00:00 GMT. The browser caches the resource as well as these header values.

  2. Subsequent Request: Now the user visits another page or reloads, and the browser needs /styles.css again. This time, instead of just sending an unconditional GET, the browser issues a conditional GET: it includes the previously stored validators in the request. For example, it sends:

    GET /styles.css HTTP/1.1
    Host: example.com
    If-None-Match: "abc123"
    If-Modified-Since: Tue, 15 Sep 2025 11:00:00 GMT

  3. These headers effectively say, “Give me /styles.css only if it’s different from what I have (ETag abc123) or if it’s been modified since 11:00 GMT Sept 15, 2025.”

  4. Server Check: The server receives this request and checks the current version of /styles.css. It compares the current ETag and last modified date of the file to the values provided by the client:

    • If the resource is unchanged: The current ETag still matches "abc123" (and the last modified date hasn’t changed). This means the client’s copy is up-to-date. The server responds with HTTP 304 Not Modified, and does not send the file again. The response is very small (just headers) and tells the browser its cached copy is still valid. The browser then loads the CSS from its cache, avoiding any download delay.

    • If the resource has changed: Suppose the CSS was updated on the server (the ETag is now different, say "xyz789", or the Last-Modified is newer). In this case, the server responds with 200 OK and the new content of /styles.css in the body, plus new ETag: "xyz789" and Last-Modified headers. The browser receives the updated file and replaces its cache with this new version for future requests.

  5. Outcome: In the unchanged scenario, the conditional request spared both parties from transferring the entire CSS file again. The 304 Not Modified response is tiny (just a few bytes of headers) compared to the file, so it loads much faster and uses minimal bandwidth. The server also didn’t have to spend time sending the file. In the changed scenario, the client got the update it needed. Either way, the conditional request ensured that the file is downloaded only when necessary, keeping the load as low as possible.

This example demonstrates the elegance of HTTP conditional requests: the client and server perform a quick check (“Has it changed?”) instead of blindly re-fetching everything.

Over millions of requests, this greatly reduces redundant data transfer and processing.

In fact, without the 304/conditional request mechanism, web caching would be far less effective. Browsers would have to either use potentially stale files or re-download all resources on each visit, which would be slow and data-heavy.

Conclusion

HTTP conditional requests (using ETags and Last-Modified dates with the corresponding If-None-Match/If-Modified-Since headers) are a cornerstone of modern web optimization.

They ensure that clients download only what they need, when they need it, and no more.

By validating caches and leveraging the 304 Not Modified response, they dramatically reduce bandwidth usage, decrease server workload, and speed up web pages.

This system benefits everyone: users enjoy faster load times, servers handle traffic more easily, and even search engines can crawl sites more efficiently.

In summary, conditional requests are a simple yet powerful concept. They ask “has this changed?” and if not, the best answer is just: “Nothing new, use what you have.”

🤖 Don't fully get this? Learn it with Claude

Stuck on What are HTTP Conditional Requests ETag, If‑None‑Match, Last‑Modified and How They Reduce Load? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **What are HTTP Conditional Requests ETag, If‑None‑Match, Last‑Modified and How They Reduce Load** (System Design) and want to truly understand it. Explain What are HTTP Conditional Requests ETag, If‑None‑Match, Last‑Modified and How They Reduce Load from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **What are HTTP Conditional Requests ETag, If‑None‑Match, Last‑Modified and How They Reduce Load** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **What are HTTP Conditional Requests ETag, If‑None‑Match, Last‑Modified and How They Reduce Load** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **What are HTTP Conditional Requests ETag, If‑None‑Match, Last‑Modified and How They Reduce Load** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes