net: Ignore pragma: no-cache if cache-control is understood (#38946)

This PR fixes a failed WPT:
https://wpt.fyi/results/fetch/http-cache/pragma-no-cache-with-cache-control.html?product=servo

[As RFC9111
mentions,](https://www.rfc-editor.org/rfc/rfc9111.html#section-5.4) the
Pragma header field is deprecated. And, in WPT, it expects the Pragma
header field is ignored if a cache-control header field is specified and
understood by UA.



Testing: running `./mach test-wpt
fetch/http-cache/pragma-no-cache-with-cache-control.html`

---------

Signed-off-by: araya <araya@araya.dev>
This commit is contained in:
araya 2025-08-27 19:11:45 +09:00 committed by GitHub
parent 33e934421e
commit ebaf78116a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 4 deletions

View file

@ -146,7 +146,8 @@ fn response_is_cacheable(metadata: &Metadata) -> bool {
directive.max_age().is_some() ||
directive.no_cache()
{
is_cacheable = true;
// If cache-control is understood, we can use it and ignore pragma.
return true;
}
}
if let Some(pragma) = headers.typed_get::<Pragma>() {

View file

@ -1,3 +0,0 @@
[pragma-no-cache-with-cache-control.html]
[Response with Cache-Control: max-age=2592000, public and Pragma: no-cache should be cached]
expected: FAIL