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: ServeContent add Cache-Control header #47539

Closed
mhewedy opened this issue Aug 4, 2021 · 3 comments
Closed

net/http: ServeContent add Cache-Control header #47539

mhewedy opened this issue Aug 4, 2021 · 3 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.

Comments

@mhewedy
Copy link

mhewedy commented Aug 4, 2021

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

$ go version
go version go1.16.5 darwin/amd64

Does this issue reproduce with the latest release?

I don't know

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/mhewedy/Library/Caches/go-build"
GOENV="/Users/mhewedy/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/mhewedy/.go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/mhewedy/.go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.16.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.16.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.5"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_m/6fmdhfh952d1kvxm2h85c2rm0000gn/T/go-build4269072314=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

calling http.ServeContent to serve file from the server, it doesn't send "Cache-Control" header at all, and even the source code fs.go doesn't mention it.

What did you expect to see?

According to retrofit (the famous Android HTTP client), it needs to see Cache-Control with value must-revalidate on the response header so it can send the HTTP request with "if-modified-since" HTTP request header. and hence http.ServeContent doesn't send such a header, then the resources are kept in Retrofit cache forever.

What did you see instead?

http.ServeContent doesn't send "Cache-Control" response header at all.

@seankhliao seankhliao changed the title http.ServeContent doesn't send cache-control by default net/http: ServeContent add Cache-Control header Aug 7, 2021
@seankhliao seankhliao added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Aug 7, 2021
@seankhliao
Copy link
Member

cc @neild

@neild
Copy link
Contributor

neild commented Aug 8, 2021

Given that there isn't a universally correct Cache-Control value, not setting one by default and leaving it up to the user to it if desired seems like the best approach.

@seankhliao
Copy link
Member

Working as expected

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 20, 2022
@golang golang locked and limited conversation to collaborators Aug 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

4 participants