Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uv-client: switch heuristic freshness lifetime to hard-coded value #5654

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

BurntSushi
Copy link
Member

The comment in the code explains the bulk of this:

// We previously computed this heuristic freshness lifetime by
// looking at the difference between the last modified header and
// the response's date header. We then asserted that the cached
// response ought to be "fresh" for 10% of that interval.
//
// It turns out that this can result in very long freshness
// lifetimes[1] that lead to uv caching too aggressively.
//
// Since PyPI sets a max-age of 600 seconds and since we're
// principally just interacting with Python package indices here,
// we just assume a freshness lifetime equal to what PyPI has.
//
// Note though that a better solution here is for the index to
// support proper HTTP caching headers (ideally Cache-Control, but
// Expires also works too, as above).

We also remove the heuristic_percent field on CacheConfig. And since
that's actually part of the cache itself, we bump the simple cache
version.

Finally, we add some more trace! calls that should hopefully make
diagnosing issues related to the freshness lifetime a bit easier in the
future.

Fixes #5351

@charliermarsh
Copy link
Member

Thanks @BurntSushi!

@charliermarsh charliermarsh added the cache Caching of packages and metadata label Jul 31, 2024
@BurntSushi BurntSushi force-pushed the ag/tweak-http-cache-heuristic branch 2 times, most recently from bc163bb to 4407427 Compare July 31, 2024 14:28
The comment in the code explains the bulk of this:

```rust
// We previously computed this heuristic freshness lifetime by
// looking at the difference between the last modified header and
// the response's date header. We then asserted that the cached
// response ought to be "fresh" for 10% of that interval.
//
// It turns out that this can result in very long freshness
// lifetimes[1] that lead to uv caching too aggressively.
//
// Since PyPI sets a max-age of 600 seconds and since we're
// principally just interacting with Python package indices here,
// we just assume a freshness lifetime equal to what PyPI has.
//
// Note though that a better solution here is for the index to
// support proper HTTP caching headers (ideally Cache-Control, but
// Expires also works too, as above).
```

We also remove the `heuristic_percent` field on `CacheConfig`. Since
that's actually part of the cache itself, we bump the simple cache
version.

Finally, we add some more `trace!` calls that should hopefully make
diagnosing issues related to the freshness lifetime a bit easier in the
future.

Fixes #5351
@BurntSushi BurntSushi force-pushed the ag/tweak-http-cache-heuristic branch from 4407427 to 299d189 Compare July 31, 2024 15:02
@BurntSushi BurntSushi merged commit 5b8ed92 into main Jul 31, 2024
57 checks passed
@BurntSushi BurntSushi deleted the ag/tweak-http-cache-heuristic branch July 31, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cache Caching of packages and metadata
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Odd UV Cache behaviour around freshly published package
3 participants