mirror of https://github.com/jlelse/GoBlog
Login form with 200 and no cache header
This commit is contained in:
parent
e25199b2a3
commit
6de2ae6ff3
|
@ -42,7 +42,8 @@ func authMiddleware(next http.Handler) http.Handler {
|
|||
return
|
||||
}
|
||||
// 3. Show login form
|
||||
w.WriteHeader(http.StatusUnauthorized)
|
||||
w.WriteHeader(http.StatusOK)
|
||||
w.Header().Set("Cache-Control", "no-cache,no-store,must-revalidate")
|
||||
h, _ := json.Marshal(r.Header.Clone())
|
||||
b, _ := io.ReadAll(io.LimitReader(r.Body, 2000000)) // Only allow 20 Megabyte
|
||||
_ = r.Body.Close()
|
||||
|
|
2
cache.go
2
cache.go
|
@ -178,8 +178,10 @@ func getCache(key string, next http.Handler, r *http.Request) (item *cacheItem)
|
|||
body: body,
|
||||
}
|
||||
// Save cache
|
||||
if cch := item.header.Get("Cache-Control"); !strings.Contains(cch, "no-store") && !strings.Contains(cch, "private") && !strings.Contains(cch, "no-cache") {
|
||||
cacheLru.Add(key, item)
|
||||
}
|
||||
}
|
||||
return item
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue