|
| 1 | +--- |
| 2 | +title: "ETAG-WEAK" |
| 3 | +description: "CAP-ETAG-WEAK capability test documentation" |
| 4 | +weight: 18 |
| 5 | +--- |
| 6 | + |
| 7 | +| | | |
| 8 | +|---|---| |
| 9 | +| **Test ID** | `CAP-ETAG-WEAK` | |
| 10 | +| **Category** | Capabilities | |
| 11 | +| **Type** | Sequence (2 steps) | |
| 12 | +| **Scored** | No | |
| 13 | +| **RFC** | [RFC 9110 §13.1.2](https://www.rfc-editor.org/rfc/rfc9110#section-13.1.2) | |
| 14 | +| **RFC Level** | SHOULD | |
| 15 | +| **Expected** | `304` | |
| 16 | + |
| 17 | +## What it does |
| 18 | + |
| 19 | +This is a **sequence test** — it captures the server's ETag and resends it with a `W/` weak prefix in `If-None-Match` to test whether the server uses the weak comparison function for GET requests. |
| 20 | + |
| 21 | +### Step 1: Initial GET (capture ETag) |
| 22 | + |
| 23 | +```http |
| 24 | +GET / HTTP/1.1\r\n |
| 25 | +Host: localhost:8080\r\n |
| 26 | +Connection: keep-alive\r\n |
| 27 | +\r\n |
| 28 | +``` |
| 29 | + |
| 30 | +Captures the `ETag` header from the response. If the ETag is strong (e.g., `"abc123"`), step 2 will prepend `W/` to make it weak (`W/"abc123"`). If already weak, it is sent as-is. |
| 31 | + |
| 32 | +### Step 2: Conditional GET (If-None-Match: W/etag) |
| 33 | + |
| 34 | +```http |
| 35 | +GET / HTTP/1.1\r\n |
| 36 | +Host: localhost:8080\r\n |
| 37 | +If-None-Match: W/"abc123"\r\n |
| 38 | +\r\n |
| 39 | +``` |
| 40 | + |
| 41 | +The weak ETag should still match via the weak comparison function, which only compares the opaque-tag portion. |
| 42 | + |
| 43 | +## What the RFC says |
| 44 | + |
| 45 | +> "A recipient MUST use the weak comparison function when comparing entity-tags for If-None-Match." — RFC 9110 §13.1.2 |
| 46 | +
|
| 47 | +The weak comparison function is defined as: "two entity-tags are equivalent if their opaque-tags match character-by-character, regardless of either or both being tagged as 'weak'." |
| 48 | + |
| 49 | +## Why it matters |
| 50 | + |
| 51 | +GET conditional requests must use weak comparison. A server that only does byte-for-byte matching of the full ETag string (including `W/` prefix) will fail to match weak ETags, causing unnecessary full responses for cacheable content. |
| 52 | + |
| 53 | +## Verdicts |
| 54 | + |
| 55 | +- **Pass** — Step 2 returns `304` (weak comparison matched) |
| 56 | +- **Warn** — No ETag in step 1, or step 2 returns `200` (server didn't use weak comparison) |
| 57 | +- **Fail** — Unexpected error (non-2xx/304 response) |
| 58 | + |
| 59 | +## Sources |
| 60 | + |
| 61 | +- [RFC 9110 §13.1.2](https://www.rfc-editor.org/rfc/rfc9110#section-13.1.2) |
| 62 | +- [RFC 9110 §8.8.3.2](https://www.rfc-editor.org/rfc/rfc9110#section-8.8.3.2) |
0 commit comments