remove expires header in no-cache cases (#4942)

This commit is contained in:
Florian Schade
2022-11-01 15:06:17 +01:00
committed by GitHub
parent 20174215d2
commit 52d618ef50
+6 -8
View File
@@ -22,24 +22,21 @@ func (f *fileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
upath := path.Clean(path.Join("/", r.URL.Path))
r.URL.Path = upath
disableCache := func() {
w.Header().Set("Cache-Control", "no-cache")
}
handleIndex := func() {
disableCache()
fallbackIndex := func() {
r.URL.Path = "/index.html"
f.ServeHTTP(w, r)
}
asset, err := f.root.Open(upath)
if err != nil {
handleIndex()
fallbackIndex()
return
}
defer asset.Close()
s, _ := asset.Stat()
if s.IsDir() {
handleIndex()
fallbackIndex()
return
}
@@ -49,7 +46,8 @@ func (f *fileServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
switch s.Name() {
case "index.html", "oidc-callback.html", "oidc-silent-redirect.html":
disableCache()
w.Header().Del("Expires")
w.Header().Set("Cache-Control", "no-cache")
_ = withBase(buf, asset, "/")
default:
_, _ = buf.ReadFrom(asset)