Home
← All questions

What is an ETag? | Web Fundamentals

MediumPremiumWeb Fundamentals

Web Fundamentals interview practice: Explain ETags and conditional requests for HTTP caching.

Answer

An ETag (Entity Tag) is a response header containing a hash/version identifier for a resource. It enables conditional requests so the browser can revalidate cached content without re-downloading it.

Flow:

  1. Server sends ETag: "abc123" with the resource.
  2. On the next request the browser sends If-None-Match: "abc123".
  3. If unchanged, the server replies 304 Not Modified (empty body) → browser uses its cache.
  4. If changed, server returns 200 with the new body and a new ETag.

This saves bandwidth and is more precise than Last-Modified/If-Modified-Since (which is second-granularity only).

# Response
ETag: "686897696a7c876b7e"
# Subsequent request
If-None-Match: "686897696a7c876b7e"
# Response if unchanged
HTTP/1.1 304 Not Modified

Strong vs weak: W/"..." is a weak validator (semantically equivalent, not byte-identical).

Premium question

Unlock the full model answer with Mentoxis Premium.

Unlock with Premium