Skip to content

feat(ads-client): respect server max-age in cache TTL resolution#7344

Open
Almaju wants to merge 2 commits intomozilla:mainfrom
Almaju:ac-103-cache-ttl-strategy
Open

feat(ads-client): respect server max-age in cache TTL resolution#7344
Almaju wants to merge 2 commits intomozilla:mainfrom
Almaju:ac-103-cache-ttl-strategy

Conversation

@Almaju
Copy link
Copy Markdown
Contributor

@Almaju Almaju commented Apr 29, 2026

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

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

@Almaju Almaju marked this pull request as ready for review May 1, 2026 19:32
Comment thread components/ads-client/src/http_cache/ttl.rs
Almaju added 2 commits May 7, 2026 13:54
Resolve effective TTL by priority via a new EffectiveTtl helper —
explicit per-request TTL wins, otherwise the response's
Cache-Control: max-age is used, otherwise the configured default_ttl.

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
Apply a 7-day ceiling to the resolved effective TTL regardless of
source. Without it, a misconfigured server max-age (e.g. years) or an
oversized caller/default value would persist responses far longer than
is reasonable for this cache.

AC-103
@Almaju Almaju force-pushed the ac-103-cache-ttl-strategy branch from fc40827 to df8cc99 Compare May 7, 2026 17:57
@Almaju Almaju enabled auto-merge May 7, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants