fix(cache): combine duplicate headers for Vary matching (#36476)
## Summary
- make `Vary: *` cache entries never match in both the SQLite and remote
cache backends
- compare the combined value of every request header named by `Vary`,
preserving value order
- preserve repeated request and response headers in remote cache
metadata, including repeated `Vary` fields
## Details
Cache matching previously compared only the first tuple for a repeated
request
header. That differed from Fetch header-list semantics, where all
matching values
are joined in their original order with `, ` separators.
`Vary: *` was also treated like a missing request header: neither
request had a
header named `*`, so the two missing values compared equal and the
cached
response matched. Both cache matchers now return no match for `Vary: *`.
The remote cache backend also used replacement insertion while
constructing its
HTTP metadata, which discarded earlier repeated request and response
fields. It
now appends those fields and combines repeated values in insertion order
during
matching. This also ensures every field named across repeated `Vary`
headers is
checked.
Coverage includes matching and mismatching combined values, value order,
missing
values, repeated `Vary` fields, `Vary: *`, and Cache API behavior.
## Validation
- `cargo test -p deno_cache --features deno_core/v8`
- `cargo test -p unit_tests --test unit -- cache_api_test`
- `cargo clippy -p deno_cache --all-targets --features deno_core/v8 --
-D warnings`
- `./tools/format.js --check`
- `./tools/lint.js --js`