-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http: Client should cache 301/308 redirect #29776
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
/cc @bradfitz |
Never considered either way. |
The http.Client does no caching of responses at all. It's not just 301/308. What is the context here? Is there a situation where this is causing problems? Also, if you are making the same request repeatedly, why is it problematic to be repeating the redirected call but not problematic to be repeating the final call? |
I believe @Gaillard filed this issue since |
The issue though is that what happens if we have uncapped/unlimited response caching and many responses are cached; what if a server responds with refresh deadline/tokens in the 301/308 responses? |
@neild @bradfitz what do y'all think about the points that I raised here #29776 (comment)? Or perhaps we can use some sort of bounded cache or perhaps an LRU of fixed size containing domain+code whose keys when being evicted pop from the map[domain+code]->response |
I don't think the defaults for net/http should have any caching at all, my expectation is for requests to correspond directly to requests sent on the wire. |
closing as working as intended. |
What version of Go are you using (
go version
)?go1.11.1
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?linux amd64, android arm
What did you do?
Used http.Client for multiple calls against a url that returns 301 or 308.
What did you expect to see?
Second invocation to use a cached response from the first.
What did you see instead?
The first call before the Location is followed is always made.
Is there any reason this choice was made or has the logic just never been put in?
The text was updated successfully, but these errors were encountered: