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

net/http: Client should cache 301/308 redirect #29776

Open
gaillard opened this issue Jan 17, 2019 · 5 comments
Open

net/http: Client should cache 301/308 redirect #29776

gaillard opened this issue Jan 17, 2019 · 5 comments
Labels
Milestone

Comments

@gaillard
Copy link

@gaillard gaillard commented Jan 17, 2019

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?

@agnivade
Copy link
Contributor

@agnivade agnivade commented Jan 17, 2019

/cc @bradfitz

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Jan 17, 2019

Never considered either way.

@bradfitz bradfitz added this to the Go1.13 milestone Jan 17, 2019
@rsc
Copy link
Contributor

@rsc rsc commented May 1, 2019

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?

@rsc rsc modified the milestones: Go1.13, Go1.14 May 1, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@odeke-em
Copy link
Member

@odeke-em odeke-em commented Oct 14, 2019

I believe @gaillard filed this issue since 301: Moved Permanently and 308: Permanent Redirect both have permanency in them, thus we can assume that those responses will never change, so perhaps we can consider these as cacheable.

@odeke-em
Copy link
Member

@odeke-em odeke-em commented Oct 14, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
@bradfitz @rsc @gaillard @agnivade @odeke-em and others
You can’t perform that action at this time.