feat(ads-client): respect server max-age in cache TTL resolution#7344
Draft
Almaju wants to merge 6 commits intomozilla:mainfrom
Draft
feat(ads-client): respect server max-age in cache TTL resolution#7344Almaju wants to merge 6 commits intomozilla:mainfrom
Almaju wants to merge 6 commits intomozilla:mainfrom
Conversation
Resolve effective TTL by priority — explicit per-request TTL wins, otherwise the response's Cache-Control: max-age is used, otherwise the configured default_ttl. Result is capped at 7 days for safety. Previously the layer took the min of all three, which collapsed to the short default_ttl in practice and ignored the server's max-age signal. AC-103
Move the priority-chain TTL resolution out of `CacheControl::effective_ttl`
into a dedicated `ttl` module with a `resolve_ttl(TtlInputs { ... })`
free function. The named-fields struct labels each input at the call
site, making the source of every value (caller / server / config) clear.
`CacheControl` is now back to its original job — parsing the response's
Cache-Control header — and exposes `max_age_duration()` for callers that
want a `Duration` instead of raw seconds.
Move the TTL resolution from a free function into an inherent method on TtlInputs, and drop pub(super) restrictions in favor of plain pub (visibility is already bounded by the private ttl module).
Drop the shared DEFAULT_TTL/MIN_TTL/MAX_TTL constants and the builder's TTL/max-size range validation. The http_cache module now trusts whatever the caller configures and no longer caps server-supplied max-age values. This keeps http_cache standalone and free of policy decisions; deciding what counts as a reasonable TTL or cache size is the consumer's job. Drops the InvalidTtl and InvalidMaxSize variants from HttpCacheBuilderError as a result.
The struct represents the concept being computed (the effective TTL),
not a parameter pack — `EffectiveTtl { ... }.resolve()` reads more
naturally at the call site.
Roll back the bounds-removal changes from this branch. Cache size and TTL validation in HttpCacheBuilder, the InvalidMaxSize/InvalidTtl error variants, and their telemetry codes are restored to match main. Those changes are out of scope for AC-103 (the priority-order TTL resolution) and should be revisited separately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolve effective TTL by priority — explicit per-request TTL wins, otherwise the response's Cache-Control: max-age is used, otherwise the configured default_ttl. Result is capped at 7 days for safety.
Previously the layer took the min of all three, which collapsed to the short default_ttl in practice and ignored the server's max-age signal.
AC-103
Pull Request checklist
[ci full]to the PR title.