From ebaf78116aab6afad5fccda3d8ee7a519803368f Mon Sep 17 00:00:00 2001 From: araya Date: Wed, 27 Aug 2025 19:11:45 +0900 Subject: [PATCH] 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 --- components/net/http_cache.rs | 3 ++- .../http-cache/pragma-no-cache-with-cache-control.html.ini | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) delete mode 100644 tests/wpt/meta/fetch/http-cache/pragma-no-cache-with-cache-control.html.ini diff --git a/components/net/http_cache.rs b/components/net/http_cache.rs index b6cd741f3ed..94a6331bb30 100644 --- a/components/net/http_cache.rs +++ b/components/net/http_cache.rs @@ -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::() { diff --git a/tests/wpt/meta/fetch/http-cache/pragma-no-cache-with-cache-control.html.ini b/tests/wpt/meta/fetch/http-cache/pragma-no-cache-with-cache-control.html.ini deleted file mode 100644 index 5e3ad18d789..00000000000 --- a/tests/wpt/meta/fetch/http-cache/pragma-no-cache-with-cache-control.html.ini +++ /dev/null @@ -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