Improve HTTP response caching log messages (#15067)
Some checks are pending
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / build binary | linux libc (push) Blocked by required conditions
CI / build binary | linux aarch64 (push) Blocked by required conditions
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / build binary | msrv (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / smoke test | linux aarch64 (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | aarch64 windows implicit (push) Blocked by required conditions
CI / integration test | aarch64 windows explicit (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | pyodide on ubuntu (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | registries (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | graalpy on ubuntu (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | aarch64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks | walltime aarch64 linux (push) Blocked by required conditions
CI / benchmarks | instrumented (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions

"Cached request ... is not storable" doesn't make sense from a user
perspective, it's leaking our internal `CachedClient` abstraction. I
think it makes more sense to talk about this as "Response from ... is
not storable"
This commit is contained in:
Zanie Blue 2025-08-05 14:34:12 -05:00 committed by GitHub
parent 3f83390e34
commit b2e7b2b279
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 27 additions and 27 deletions

View file

@ -517,7 +517,7 @@ impl CachedClient {
BeforeRequest::NoMatch => {
// This shouldn't happen; if it does, we'll override the cache.
warn!(
"Cached request doesn't match current request for: {}",
"Cached response doesn't match current request for: {}",
req.url()
);
let (response, cache_policy) = self.fresh_request(req, cache_control).await?;

View file

@ -563,7 +563,7 @@ impl ArchivedCachePolicy {
ArchivedMethod::Get | ArchivedMethod::Head
) {
tracing::trace!(
"Cached request {} is not storable because of its method {:?}",
"Response from {} is not storable because of the request method {:?}",
self.request.uri,
self.request.method
);
@ -575,8 +575,8 @@ impl ArchivedCachePolicy {
// below, but we can bail out early here.
if !self.response.has_final_status() {
tracing::trace!(
"Cached request {} is not storable because its response has \
non-final status code {:?}",
"Response from {} is not storable because it has \
a non-final status code {:?}",
self.request.uri,
self.response.status,
);
@ -591,8 +591,8 @@ impl ArchivedCachePolicy {
// itself.
if self.response.status == 206 || self.response.status == 304 {
tracing::trace!(
"Cached request {} is not storable because its response has \
unsupported status code {:?}",
"Response from {} is not storable because it has \
an unsupported status code {:?}",
self.request.uri,
self.response.status,
);
@ -605,7 +605,7 @@ impl ArchivedCachePolicy {
// S3.)
if self.request.headers.cc.no_store {
tracing::trace!(
"Cached request {} is not storable because its request has \
"Response from {} is not storable because its request has \
a 'no-store' cache-control directive",
self.request.uri,
);
@ -614,7 +614,7 @@ impl ArchivedCachePolicy {
// "the no-store cache directive is not present in the response"
if self.response.headers.cc.no_store {
tracing::trace!(
"Cached request {} is not storable because its response has \
"Response from {} is not storable because it has \
a 'no-store' cache-control directive",
self.request.uri,
);
@ -631,8 +631,8 @@ impl ArchivedCachePolicy {
// private).
if self.response.headers.cc.private {
tracing::trace!(
"Cached request {} is not storable because this is a shared \
cache and its response has a 'private' cache-control directive",
"Response from {} is not storable because this is a shared \
cache and has a 'private' cache-control directive",
self.request.uri,
);
return false;
@ -642,7 +642,7 @@ impl ArchivedCachePolicy {
// explicitly allows shared caching"
if self.request.headers.authorization && !self.allows_authorization_storage() {
tracing::trace!(
"Cached request {} is not storable because this is a shared \
"Response from {} is not storable because this is a shared \
cache and the request has an 'Authorization' header set and \
the response has indicated that caching requests with an \
'Authorization' header is allowed",
@ -657,7 +657,7 @@ impl ArchivedCachePolicy {
// "a public response directive"
if self.response.headers.cc.public {
tracing::trace!(
"Cached request {} is storable because its response has \
"Response from {} is storable because it has \
a 'public' cache-control directive",
self.request.uri,
);
@ -666,8 +666,8 @@ impl ArchivedCachePolicy {
// "a private response directive, if the cache is not shared"
if !self.config.shared && self.response.headers.cc.private {
tracing::trace!(
"Cached request {} is storable because this is a shared cache \
and its response has a 'private' cache-control directive",
"Response from {} is storable because this is a shared cache \
and has a 'private' cache-control directive",
self.request.uri,
);
return true;
@ -675,7 +675,7 @@ impl ArchivedCachePolicy {
// "an Expires header field"
if self.response.headers.expires_unix_timestamp.is_some() {
tracing::trace!(
"Cached request {} is storable because its response has an \
"Response from {} is storable because it has an \
'Expires' header set",
self.request.uri,
);
@ -684,7 +684,7 @@ impl ArchivedCachePolicy {
// "a max-age response directive"
if self.response.headers.cc.max_age_seconds.is_some() {
tracing::trace!(
"Cached request {} is storable because its response has an \
"Response from {} is storable because it has an \
'max-age' cache-control directive",
self.request.uri,
);
@ -693,8 +693,8 @@ impl ArchivedCachePolicy {
// "if the cache is shared: an s-maxage response directive"
if self.config.shared && self.response.headers.cc.s_maxage_seconds.is_some() {
tracing::trace!(
"Cached request {} is storable because this is a shared cache \
and its response has a 's-maxage' cache-control directive",
"Response from {} is storable because this is a shared cache \
and has a 's-maxage' cache-control directive",
self.request.uri,
);
return true;
@ -705,7 +705,7 @@ impl ArchivedCachePolicy {
// "a status code that is defined as heuristically cacheable"
if HEURISTICALLY_CACHEABLE_STATUS_CODES.contains(&self.response.status.into()) {
tracing::trace!(
"Cached request {} is storable because its response has a \
"Response from {} is storable because it has a \
heuristically cacheable status code {:?}",
self.request.uri,
self.response.status,
@ -713,7 +713,7 @@ impl ArchivedCachePolicy {
return true;
}
tracing::trace!(
"Cached response {} is not storable because it does not meet any \
"Response from {} is not storable because it does not meet any \
of the necessary criteria (e.g., it doesn't have an 'Expires' \
header set or a 'max-age' cache-control directive)",
self.request.uri,
@ -766,7 +766,7 @@ impl ArchivedCachePolicy {
// [RFC 9111 S5.2.1.4]: https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.1.4
if reqcc.no_cache {
tracing::trace!(
"Request {} does not have a fresh cache because \
"Request to {} does not have a fresh cache entry because \
it has a 'no-cache' cache-control directive",
request.url(),
);
@ -780,7 +780,7 @@ impl ArchivedCachePolicy {
if let Some(&max_age) = reqcc.max_age_seconds.as_ref() {
if age > max_age {
tracing::trace!(
"Request {} does not have a fresh cache because \
"Request to {} does not have a fresh cache entry because \
the cached response's age is {} seconds and the max age \
allowed by the request is {} seconds",
request.url(),
@ -800,7 +800,7 @@ impl ArchivedCachePolicy {
let time_to_live = freshness_lifetime.saturating_sub(unix_timestamp(now));
if time_to_live < min_fresh {
tracing::trace!(
"Request {} does not have a fresh cache because \
"Request to {} does not have a fresh cache entry because \
the request set a 'min-fresh' cache-control directive, \
and its time-to-live is {} seconds but it needs to be \
at least {} seconds",
@ -818,7 +818,7 @@ impl ArchivedCachePolicy {
let allows_stale = self.allows_stale(now);
if !allows_stale {
tracing::trace!(
"Request {} does not have a fresh cache because \
"Request to {} does not have a fresh cache entry because \
its age is {} seconds, it is greater than the freshness \
lifetime of {} seconds and stale cached responses are not \
allowed",
@ -846,7 +846,7 @@ impl ArchivedCachePolicy {
// [RFC 9111 S5.2.2.2]: https://www.rfc-editor.org/rfc/rfc9111.html#section-5.2.2.2
if self.response.headers.cc.must_revalidate {
tracing::trace!(
"Cached request {} has a cached response that does not \
"Request to {} has a cached response that does not \
permit staleness because the response has a 'must-revalidate' \
cache-control directive set",
self.request.uri,
@ -865,7 +865,7 @@ impl ArchivedCachePolicy {
.saturating_sub(self.freshness_lifetime().as_secs());
if stale_amount <= max_stale.into() {
tracing::trace!(
"Cached request {} has a cached response that allows staleness \
"Request to {} has a cached response that allows staleness \
in this case because the stale amount is {} seconds and the \
'max-stale' cache-control directive set by the cached request \
is {} seconds",
@ -885,7 +885,7 @@ impl ArchivedCachePolicy {
//
// [RFC 9111 S4.2.4]: https://www.rfc-editor.org/rfc/rfc9111.html#section-4.2.4
tracing::trace!(
"Cached request {} has a cached response that does not allow staleness",
"Request to {} has a cached response that does not allow staleness",
self.request.uri,
);
false