Skip to content

feat(http-cache)!: adds default_ttl and makes max_ttl only a limit - #176

Open
beanow-at-crabnebula wants to merge 3 commits into
06chaynes:mainfrom
beanow-at-crabnebula:beanow/default-ttl
Open

beanow-at-crabnebula wants to merge 3 commits into
06chaynes:mainfrom
beanow-at-crabnebula:beanow/default-ttl

Conversation

@beanow-at-crabnebula

Copy link
Copy Markdown
Contributor

Relates to #175

This is one possible implementation that I recommended in the issue:

  • max_ttl no longer becomes the lifetime of responses without max-age, which
    also extended shorter Expires and heuristic lifetimes.
  • default_ttl now covers responses without an explicit expiration, replacing the heuristic, but respecting max-age and Expires.

Breaking: this changes the max_ttl behavior. Migration would be to set default_ttl = max_ttl.
However that still fixes that we're now respecting Expires headers over the default.

The change should cleanly propagate to all the client crates through re-exports.
Did a check for stale comments / tests though.

Assisted-by: claude-opus-5-5

`max_ttl` no longer becomes the lifetime of responses without `max-age`, which
also extended shorter `Expires` and heuristic lifetimes. `default_ttl` now
covers responses without an explicit expiration, replacing the heuristic.

See 06chaynes#175

BREAKING CHANGE: `max_ttl` no longer caches responses without an explicit
expiration. Set `default_ttl` to the same duration to keep the previous behavior.

Assisted-by: claude-opus-5-5
…caching headers

Assisted-by: claude-opus-5-5
Examples that force-cache responses relied on `max_ttl` as their default
lifetime, so they now set `default_ttl`. Also drops the remaining claims that
`max_ttl` expires responses in `IgnoreRules`.

Assisted-by: claude-opus-5-5
@codecov

codecov Bot commented Sep 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.20319% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.19%. Comparing base (b1c3fb4) to head (920e57e).
⚠️ Report is 52 commits behind head on main.

Files with missing lines Patch % Lines
http-cache/src/lib.rs 97.10% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #176      +/-   ##
==========================================
+ Coverage   85.87%   90.19%   +4.32%     
==========================================
  Files          19       19              
  Lines        7502    11622    +4120     
==========================================
+ Hits         6442    10482    +4040     
- Misses       1060     1140      +80     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

1 participant