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: Support exact-match If-Modified-Since in http.ServeFile() #17742

Closed
georgmu opened this issue Nov 2, 2016 · 1 comment

Comments

Projects
None yet
3 participants
@georgmu
Copy link

commented Nov 2, 2016

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.7.3 linux/amd64

What did you do?

net/http has support to honor If-Modified-Since headers in http.ServeFile().

If I downgrade an application using a package manager (e.g. via rpm), the If-Modified-Since would always result in a 304 Not Modified.

src/net/http/fs.go contains the following:

if t, err := time.Parse(TimeFormat, r.Header.Get("If-Modified-Since")); err == nil && modtime.Before(t.Add(1*time.Second)) {
    ...
}

My proposal would be to have a configuration variable to only respond with 304 Not Modified on an exact match.

The exact match would be something like modtime.Truncate(time.Second).Equal(t.Truncate(time.Second))

As an example for another http server, nginx allows to serve files with "exact" match or "before" match and defaults to "exact" match:
http://nginx.org/en/docs/http/ngx_http_core_module.html#if_modified_since

@bradfitz

This comment has been minimized.

Copy link
Member

commented Nov 2, 2016

No, thanks. I think you should use ETags if you want exact matches.

Otherwise we'll follow the RFCs and not add configuration for non-standard behavior.

/cc @tombergan

@bradfitz bradfitz closed this Nov 2, 2016

@golang golang locked and limited conversation to collaborators Nov 2, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.