Use both when you can, and lead with a strong ETag. An ETag is an opaque version string for a response, while Last-Modified is a timestamp. The ETag detects any change in content, and the timestamp is a coarser fallback that older caches understand. The HTTP specification sets exactly that preference for servers. Below you get how each header works, where dates break down, what weak and strong ETags mean, and how to confirm your server sends what you think it sends.
TL;DR
- ETag identifies a specific version of a resource with an opaque string. Last-Modified gives a date, with one-second resolution.
- Browsers and caches revalidate with
If-None-Match(ETag) orIf-Modified-Since(date). A match returns a bodyless304 Not Modified. - A strong ETag changes whenever the bytes change. A weak ETag, marked
W/, only promises that the content is equivalent. - Send both validators when feasible. Prefer a strong ETag, and add Last-Modified for compatibility.
- Check the real headers on the wire, because proxies, compression and frameworks often rewrite them.
Table of Contents
- What validators are and why they exist
- ETag vs Last-Modified at a glance
- How Last-Modified works, and where it falls short
- How ETag works
- Weak vs strong ETags
- What happens when both validators are present
- ETags beyond caching: conditional writes
- Which one should you use?
- Common mistakes
- Check what your server actually sends
- Pingfloat for the rest of your header and uptime checks
- Our perspective
- FAQ
- Sources
What validators are and why they exist
A cache stores a response and serves it while it is fresh. Freshness is controlled by Cache-Control, which we cover in our guide to Cache-Control headers. Once the stored copy goes stale, the cache does not have to download the resource again. It can ask the server whether its copy is still the right one.
That question needs something to compare. According to MDN's guide to conditional requests, validators describe a version of a resource in one of two ways: the last-modified date, or an opaque string, the entity tag (ETag), that identifies each version uniquely. Those two are the whole subject of this article.
The flow is the same for both:
- The first response carries a validator, for example
ETag: "33a64df5"orLast-Modified: Wed, 21 Oct 2026 07:28:00 GMT. - The client stores the response together with the validator.
- When the copy is stale, the client sends a conditional request that echoes the validator back.
- If the resource has not changed, the server answers
304 Not Modifiedwith no body. Otherwise it answers200 OKwith the new content and new validators.
The saving is the body. A 304 is a few hundred bytes of headers instead of a full page, script or JSON payload. You can look up each code in our HTTP status codes reference.
ETag vs Last-Modified at a glance
| ETag | Last-Modified | |
|---|---|---|
| What it is | Opaque quoted string identifying a version | HTTP date of the last change |
| Request header used | If-None-Match, If-Match, If-Range | If-Modified-Since, If-Unmodified-Since, If-Range |
| Resolution | Any change you can fingerprint | One second |
| Strength | Strong by default, weak with W/ | Treated as weak unless context proves otherwise |
| Cost to generate | Needs a hash or revision id | Cheap if you store a modification time |
| Best for | Dynamic content, APIs, range requests, update conflicts | Static files and content that already has reliable timestamps |
The request header names come from RFC 9111, which says a cache validating a stored response sends entity tags using If-Match, If-None-Match or If-Range, and sends the Last-Modified value using If-Modified-Since, or If-Unmodified-Since and If-Range for subrange requests.
How Last-Modified works, and where it falls short
Last-Modified tells the client when the origin server believes the representation last changed. For a static file, that is the file's modification time on disk, which is why web servers send it for images, stylesheets and scripts without any configuration.
A revalidation looks like this:
GET /app.css HTTP/1.1
If-Modified-Since: Wed, 21 Oct 2026 07:28:00 GMT
HTTP/1.1 304 Not Modified
Dates are cheap and familiar, but they have three weak spots.
One-second resolution. HTTP dates have no sub-second part. If a resource is updated twice within the same second, two different bodies can carry the same Last-Modified value, and a client holding the first version cannot tell it is stale. That matters for APIs and any content written by automated jobs.
Timestamps that change without the content changing. A deploy that touches every file, a rebuild that rewrites identical output, or a restore from backup can all move the modification time while the bytes stay the same. Clients then re-download content they already had.
Dates are not always meaningful. Dynamically generated pages often have no natural modification time. You would have to invent one, and a wrong date is worse than none. The specification also says Last-Modified must not be later than the response's Date header, so a clock-skewed server can produce invalid values.
None of this makes Last-Modified wrong. For a folder of versioned static assets, it works well and costs nothing.

How ETag works
An ETag is a string the server chooses. The client never interprets it. It only stores it and sends it back. RFC 7232 defines it as an opaque quoted string that can carry an optional W/ prefix, for example ETag: "xyzzy" or ETag: W/"xyzzy".
Because the server decides what goes into the tag, you can make it track exactly what matters:
- a hash of the response body
- a revision number or row version from your database
- a combination of file size and modification time, which is how some web servers build theirs
The revalidation request uses If-None-Match:
GET /api/articles/42 HTTP/1.1
If-None-Match: "33a64df5"
HTTP/1.1 304 Not Modified
ETag: "33a64df5"
If the tag no longer matches, the server returns 200 OK with the full body and a new ETag. This is the flow MDN's caching guide walks through, and it is the same on every stack.
The trade-off is generation cost. Hashing a large dynamic response on every request takes CPU, and the specification itself acknowledges that strong validators can be difficult, or occasionally impossible, to generate efficiently. A common fix is to derive the tag from something you already have, such as a revision column or a content version, rather than hashing the output each time.
Weak vs strong ETags
The W/ prefix is the part of ETag that trips up most developers. It is a promise about how precise the tag is.
A strong validator changes whenever the observable representation changes, and is unique across versions of the resource over time. A weak validator may stay the same across some changes. RFC 7232 makes strong the default, and a server must mark a tag weak with W/ if it does not meet the strong requirements.
MDN gives the practical picture: strong validation is for cases where byte-for-byte identity matters, such as resuming a download, while weak validation suits cases where the client only needs to know the content is essentially the same, such as a page whose ads or footer date differ.
Comparison rules
The specification defines two ways to compare tags:
- Strong comparison: both tags must be non-weak and match character by character.
- Weak comparison: the opaque strings must match character by character, and the
W/prefix is ignored.
Which one applies depends on the header. If-None-Match uses weak comparison, so a weak ETag works fine for ordinary cache revalidation. If-Match uses strong comparison, so a weak ETag can never satisfy it.
What each strength allows
| Use case | Strong ETag | Weak ETag |
|---|---|---|
| Cache revalidation (304) | Yes | Yes |
| Resuming a download with range requests | Yes | No |
Preventing lost updates with If-Match | Yes | No |
| Content that varies trivially (ad slots, timestamps) | Awkward | Good fit |
MDN's ETag reference adds a consequence worth remembering: weak ETags disable caching for byte-range requests, while strong ETags keep range-request caching viable. If you serve large downloads or video, that matters.
When weak tags show up on their own
Many servers and proxies downgrade a strong ETag to weak when they compress a response on the fly, because the compressed bytes differ from the originals. If your origin sends a strong tag and the browser sees W/, a compression layer is a likely cause. This is one reason to inspect the headers a client actually receives, not only what your application emits.
What happens when both validators are present
Sending both is the recommended default. RFC 7232 says an origin server should send an entity tag unless that is infeasible, may send a weak tag for performance or feasibility reasons, and should send Last-Modified if feasible. The preferred combination is a strong ETag plus Last-Modified. Clients should send both validators back when they have both, so HTTP/1.0 and HTTP/1.1 caches can each respond appropriately.
RFC 9111 explains why this survives even though entity tags are clearly the better tool: old intermediaries that do not understand entity-tag preconditions can still answer a date-based request. Sending both is a compatibility decision, not redundancy for its own sake.
When a request carries both If-None-Match and If-Modified-Since, the ETag takes priority. The specification tells servers to evaluate If-None-Match and ignore If-Modified-Since when the former is present. The date is only a fallback for caches that never saw an ETag.
ETags beyond caching: conditional writes
Validators do more than save bandwidth. ETags also protect against the "mid-air collision" problem, where two clients edit the same resource and the second save silently overwrites the first.
The pattern for APIs:
- The client reads a resource and keeps its ETag.
- The client sends the update with
If-Match: "33a64df5". - If someone else changed the resource in the meantime, the tag no longer matches and the server responds
412 Precondition Failed. - The client re-reads, merges, and tries again.
This is why If-Match requires strong comparison: a lost-update check that accepts a "roughly the same" tag defeats its own purpose. Last-Modified can do the job with If-Unmodified-Since, but the one-second resolution makes it unreliable when writes are frequent. If you build or consume JSON APIs, ETags with If-Match are the cleaner tool.
Which one should you use?
Static assets (CSS, JS, images, fonts). Let the web server send both defaults. Pair them with long Cache-Control: max-age values and content-hashed filenames, so revalidation is rare anyway.
Dynamic HTML pages. Use an ETag derived from the content or a version id, with Last-Modified if the page has a trustworthy update time, such as a post's edit date. Skip a date you would have to guess.
JSON APIs. Use a strong ETag from a revision or hash. Add If-Match support on write endpoints for conflict detection.
Large downloads and media. Use strong ETags so range requests and resumed downloads stay cacheable. If you share big files with clients, our post on expiring download links covers the access side.
Multiple servers behind a load balancer. Make sure every node produces the same validator for the same content. A tag built from inode numbers or per-machine file times differs between nodes, and clients see a cache miss on nearly every other request.
Common mistakes
- Different ETags per server. Same content, different tags, no 304s. Build tags from content, not from machine-specific metadata.
- Last-Modified set to the current time. Some frameworks stamp every dynamic response with "now." That tells the cache the resource changed on every request.
- Validators with no freshness policy. Without
Cache-Control, caches may guess how long to reuse a response. Set freshness explicitly, then let validators handle revalidation. - Expecting validators to prevent stale content on their own. They only answer the question when a client asks. Freshness is what decides when it asks.
- Ignoring
Vary. If a response differs byAccept-Encodingor language, the validator must be consistent with that variant.
While auditing how a page is served, it also helps to run a canonical tag checker, since caching and canonical signals both influence which version of a URL gets served and indexed.
Check what your server actually sends
Reading config files tells you what you intended. The response headers tell you what happened after your CDN, reverse proxy and compression layer had their say. A quick check:
- Request the URL and note the
ETag,Last-ModifiedandCache-Controlheaders. - Look for a
W/prefix you did not expect. - Repeat the request with
If-None-Matchset to the tag you received and confirm you get a 304. - Repeat through each hostname or edge location that serves the content, and compare the tags.
Our Response Headers Inspector shows a URL's cache and security headers in the browser, with nothing to install. For a broader walkthrough of reading headers, see our guide to debugging HTTP headers.
Pingfloat for the rest of your header and uptime checks
Pingfloat is a free suite of web tools for developers and IT professionals. Besides inspecting response headers, you can use it for the checks that tend to come right after a caching change: an uptime monitor to watch your site's availability, an SSL checker for certificates, and a JSON formatter and traceroute for debugging. Core tools need no installation or account, and everything is on the Pingfloat home page.

Our perspective
When we debug a slow or inconsistent site, headers are the first place we look, because they show what every cache between the server and the browser was told. Validators are the quiet part of that picture. They rarely break loudly. They just make pages heavier than they should be, or serve a version nobody expected.
Our rule is simple. Treat the ETag as the source of truth and Last-Modified as the courtesy for older caches. Then verify the result from the outside, because the layers in front of your application will change things you never configured.
That outside check is the reason we built a browser-based header inspector into Pingfloat. It takes seconds, it needs no setup, and it turns an argument about what the server probably sends into a fact you can read.
Andreas
FAQ
Does ETag override Last-Modified?
When a request has both If-None-Match and If-Modified-Since, the server evaluates the ETag and ignores the date. Last-Modified remains useful for older caches that do not understand entity tags, which is why servers are advised to send both.
Is a weak ETag worse than a strong one?
Not for ordinary caching. Weak tags work with If-None-Match, so you still get 304 responses. A strong ETag is needed for range requests, resumable downloads and If-Match update checks, so choose it wherever byte-level identity matters.
Why does my server send a W/ ETag when I set a strong one?
A compression layer or proxy often converts strong tags to weak ones when it alters the bytes in transit. Inspect the headers the client receives, and compare the tag from your origin with the one at the edge.
Can I use only Last-Modified?
Yes, for static files with reliable modification times it works. For content that can change more than once per second, or whose timestamps shift on every deploy, an ETag is more accurate.
Do ETags replace Cache-Control?
No. Cache-Control decides how long a response stays fresh. ETag and Last-Modified are used after it goes stale, to confirm whether a full download is needed.
Sources
- RFC 7232: HTTP/1.1 Conditional Requests
- RFC 9111: HTTP Caching
- HTTP conditional requests, MDN
- ETag header, MDN
- HTTP caching, MDN
