-
Notifications
You must be signed in to change notification settings - Fork 123
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
Cache Deserialization (part two) -- warning message incorrect? #209
Comments
I've seen this too; the simplest way to repro is to send a request to an endpoint that serves a import logging
logging.basicConfig(level=logging.WARNING)
from cachecontrol import CacheControlAdapter
from cachecontrol.caches import SeparateBodyFileCache
from requests.adapters import HTTPAdapter
from requests.sessions import Session
cache_dir = "foo"
sess = Session()
cache_adapter = CacheControlAdapter(
cache=SeparateBodyFileCache(cache_dir)
)
sess.mount("https://", cache_adapter)
sess.get("https://pypi.org/simple/cachecontrol", headers={"Accept": "text/html"})
sess.get("https://pypi.org/simple/cachecontrol", headers={"Accept": "application/vnd.pypi.simple.v1+json"}) |
@thatch Is your solution just requesting same resource twice with different |
@dvershinin sorry I wasn't clear -- that's just a simple repro, against a well-behaved server, showing the server using |
My understanding based on @thatch's reproduction, is that there are perhaps certain keys or fields in the header that do not necessarily change the response from the server (for example the Particularly @thatch is expecting two separate caches to be made, rather than trying to (re)use the |
This is related to #148 - but I would prefer not to necro. I'm seeing this repeatedly when I make the same request over and over again. I'll detail everything I'm using right now.
Whenever I make the same request over and over (no warning the first time when there's no cache) but on subsequent requests, I get a warning...
which indicates this line here: https://github.com/ionrock/cachecontrol/blob/0234b80/cachecontrol/controller.py#L147
So I'm going manually through the steps to find where the crash/error is. I see that we're using
v4
somsgpack
is being used:No error there, so digging in more (given that there's no error on the empty request, I suspect it is not related to the cache but to the request itself...). So reverse-engineering what
serialize.py
is doing:So now I prep a request to compare against to see how
cachecontrol
works in theprepare_response
sectionTo do this part, I just insert
pdb
into the relevant section and just evaluate specific lines, but I found out that the problem is that the headers didn't match (and in fact, I'm making different requests since the Bearer Token changed between requests when I submit repeatedly since I'm not caching the access tokens).https://github.com/ionrock/cachecontrol/blob/0234b80/cachecontrol/serialize.py#L115-L119
So what ends up happening, to me, is that the warning message being spit out is not very clear at all. In fact, it just (in this case) means that the headers didn't match -- so the cache should be rebuilt. That is cache deserialization did not fail.
The text was updated successfully, but these errors were encountered: