diff --git a/authentication.go b/authentication.go index 6f052f3..0a39555 100644 --- a/authentication.go +++ b/authentication.go @@ -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() diff --git a/cache.go b/cache.go index c25813f..4a2918a 100644 --- a/cache.go +++ b/cache.go @@ -178,7 +178,9 @@ func getCache(key string, next http.Handler, r *http.Request) (item *cacheItem) body: body, } // Save cache - cacheLru.Add(key, item) + 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 }