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
No cache when no internet connection - even with forever set to True #49
Comments
It looks like cachecontrol still performs a DNS lookup. |
Is there a way to urge CacheControl to performs differently ? |
Hello, after this commit I try this
Unfortunately first try is ok (when internet is enabled) but it's still failing when internet connection is disabled. |
This doesn't change requests behavior where the DNS look up still happens. |
@sigmavirus24 I'm not seeing where CacheControl would be performing the DNS lookup. If there is a cached response we find when doing the |
requests does not do DNS look-ups. That's up to urllib3. |
One option here is to go ahead and do a DNS resolution manually on the URL before passing it into requests. That could cache the result or use some sort of a lookup. I don't see a good generic way to do this in CacheControl, but I might look into adding a DNS cache feature that provides some common tooling that could be used. |
Yeah, this could also be related to the proxy look-ups that requests does when dealing with that stuff. A complete traceback would have been really nice to have to help diagnose this. |
I worked around this by creating an adapter subclass:
Which can be instantiated like this:
|
Any interest in adding the behavior of @dsully's contribution to |
I think this use case is unique enough that someone could distribute it as its own library. I personally don't have time or interest to maintain this sort of specialized case. That said, the usage above seems totally reasonable to me for those that do want the behavior. |
Hello,
I try this code with my internet connection enabled
I disabled my internet connection and run again this code.
It raised
ConnectionError: ('Connection aborted.', gaierror(8, 'nodename nor servname provided, or not known'))
That's probably a misunderstanding from my side. But I thought that if I store in a file both request and response I could get it when my connection was disabled.
I also don't understand why this
forever
flag exists. In my understanding we should pass a custom caching strategies (aka caching heuristics) to CacheControland use it like
Any idea ? but that's like I said probably a misunderstanding from my side.
Kind regards
The text was updated successfully, but these errors were encountered: