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

404 responses on --extra-index should be cached. #13097

Open
1 task done
zopfli opened this issue Nov 30, 2024 · 2 comments
Open
1 task done

404 responses on --extra-index should be cached. #13097

zopfli opened this issue Nov 30, 2024 · 2 comments
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior

Comments

@zopfli
Copy link

zopfli commented Nov 30, 2024

Description

If packages are distributed over multiple indices, at least one index contains the requested package while the other indices will return a 404. However, this 404 response is not cached, so the non-containing index will repeatedly be queried for package existence. This hurts performance.

Expected behavior

In the cache controller, HTTP status code 404 should be cached.

pip version

main

Python version

3.10

OS

MacOS

How to Reproduce

  • Run pip compile with multiple indices, e.g. A and B.
  • Request packages from index A that are not on B, and v.v.
  • Note that B will respond 404 to attempts searching for A-exclusive packages, and v.v.
  • Note that these responses are not cached.

Output

When fetching:

Status code 404 not in (200, 203, 300, 301, 308)

and

Request header has "max_age" as 0, cache bypassed

Code of Conduct

@zopfli zopfli added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Nov 30, 2024
@zopfli
Copy link
Author

zopfli commented Dec 1, 2024

Related to #12397

@notatallshaw
Copy link
Member

notatallshaw commented Dec 1, 2024

I'm concerned about side effects this might have, such as a user uploading a package running pip install my_package==new_version, would caching the 404 prevent them from seeing the new package? Or other similar scenarios.

At the moment I believe pip checks all indexes for all packages, every request. Because the behavior of handling multiple indexes, and more so what to do with non-200 responses, is not standardized, I would be surprised if someone isn’t relying on pip’s current behavior here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants