|
37 | 37 | * |
38 | 38 | * `Vary: Accept-Encoding` goes on every response this could encode, whatever |
39 | 39 | * the request accepted and whatever the body's size, so a shared cache never |
40 | | - * hands one client's encoding to another. It also goes on the `HEAD`, `206` |
41 | | - * and `304` answers for such a response, which are never encoded themselves: |
42 | | - * a `HEAD` carries the header fields its `GET` would, and a cache refreshes a |
43 | | - * stored answer's headers from a `304`. The `ETag` is passed through |
| 40 | + * hands one client's encoding to another. It also goes on the `HEAD` and `206` |
| 41 | + * answers for such a response, which are never encoded themselves: a `HEAD` |
| 42 | + * carries the header fields its `GET` would. The rule reads the answer it is |
| 43 | + * handed, never the route's `200`, so a `304` carries it only when the `304` |
| 44 | + * itself carries a compressible `Content-Type` (the dispatcher's `res.json()` |
| 45 | + * answers do; the Console's bare stable-file `304` does not). A cache that |
| 46 | + * refreshes a stored answer from a `304` keeps the stored `Vary`, so a `304` |
| 47 | + * without one loses nothing. The `ETag` is passed through |
44 | 48 | * unchanged: the metadata and record doors compare an `If-Match` token against |
45 | 49 | * it strongly, so rewriting it to a weak `W/` form on encoded answers would make |
46 | 50 | * every save that pins the version it just read fail its precondition. |
@@ -219,8 +223,9 @@ export async function compressResponse( |
219 | 223 | if (vary !== '*' && !(vary && VARY_ACCEPT_ENCODING.test(vary))) { |
220 | 224 | c.header('Vary', vary ? `${vary}, Accept-Encoding` : 'Accept-Encoding'); |
221 | 225 | } |
222 | | - // A `HEAD`, a partial answer and a revalidation carry the `Vary` of the |
223 | | - // full answer they stand for, and are never encoded themselves. |
| 226 | + // A `HEAD`, a partial answer and a revalidation are never encoded |
| 227 | + // themselves. A `304` reaches this line only when it carries a |
| 228 | + // compressible `Content-Type` of its own: a bare `304` gets no `Vary`. |
224 | 229 | if (c.req.method === 'HEAD' || c.res.status === 206 || c.res.status === 304) return; |
225 | 230 |
|
226 | 231 | const length = declaredLength(c.res.headers); |
|
0 commit comments