-
Notifications
You must be signed in to change notification settings - Fork 3.1k
HTTP 302 Found responses with Cache Headers not being cached #13396
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
Comments
I understand the issue is about supporting caching of 302 redirects in general, but caching presigned URLs is unintuitive since they are short-lived by design. In this specific case, the max-age is set to 1 year, which is most likely a misconfiguration and would likely cause errors down the line. Given that, not caching the redirect happens to be the correct behavior. |
Is there a best practice I can point JFROG to? For the CDN/mirror deferal in their pip handshake? I am caught in the middle. I have seen customers use a simpleindex to mask the 302 to pip. I could fork/patch pip for our use case in CI process, but why? I will file/update a ticket with jfrog so they can advocate a position. Thank you. FYI, the cache header for a package less than 512K also gives a max-age of the same duration. So I am not sure how to read into provider's Cache Header usage.
|
I think the original issue about caching 302s might be coming from the wrong angle. As mentioned in psf/cachecontrol#384, the real question is, why does JFrog want to cache these short-lived presigned URLs at all, and is there a genuine benefit in doing so?
As far as I understand, the idea behind using
The All in all, caching 302s that come with appropriate cache headers might technically be okay, but I'm not sure what we'd be trying to solve. I guess that if there isn't a valid use case for pip to support, this might be better addressed on the JFrog side. |
Uh oh!
There was an error while loading. Please reload this page.
Description
The PIP HTTP cache for webservers using 302 responses for signed URLs response to package requests are failing to use the HTTP cache due to the 302 response code.
In particular this is an implementation issue with JFrog Artifactory PYPI proxy/cache which uses 302 signed URLs to point to cloud storage for requested python packages and wheels. In particular it appears JFrog uses the 302 redirect for packages larger than 512K.
Expected behavior
Given cache headers in the 302 response I would expect pip to cache the response according to the policy returned in the response. This is particularly convienient for CI processes which download large packages like PYTorch regularly.
pip version
25.1.1
Python version
3.11
OS
linux
How to Reproduce
pip install ipython==7.32.0
(This has some transitive dependencies, but ignore that)pip uninstall -y ipython
pip install ipython==7.32.0
(Ideally this would hit the HTTP Request cache)If you want to test with a smaller package to see the cache being hit for JFROG Artifactory, can use
ptyprocess==0.7.0
A related issue has been filed with the cachecontrol library: psf/cachecontrol#384
Output
This is the section of the logs which are most relvant to the issue
The HTTP Response headers for the 302 Response were:
Code of Conduct
The text was updated successfully, but these errors were encountered: