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.
The text was updated successfully, but these errors were encountered:
seankhliao
changed the title
http.ServeContent doesn't send cache-control by default
net/http: ServeContent add Cache-Control header
Aug 7, 2021
seankhliao
added
the
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
label
Aug 7, 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.
What version of Go are you using (
go version
)?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
OutputWhat 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 codefs.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.
The text was updated successfully, but these errors were encountered: