fix(backend): ensure 404s are never cached

This commit is contained in:
Łukasz Mierzwa
2022-08-05 15:12:09 +01:00
committed by Łukasz Mierzwa
parent 9908b8f573
commit 41ce597cf5
2 changed files with 9 additions and 2 deletions

View File

@@ -99,6 +99,13 @@ func setupRouter(router *chi.Mux, historyPoller *historyPoller) {
MaxAge: 300,
}))
router.NotFound(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
contentText(w)
w.WriteHeader(http.StatusNotFound)
_, _ = w.Write([]byte("Not found"))
})
allowAuthBypass := []string{
getViewURL("/health"),
getViewURL("/metrics"),

View File

@@ -28,8 +28,8 @@ level=info msg="Removing PID file" path=karma.pid
-- query.json --
{
"sources": [
"http://127.0.0.1:9099",
"http://127.0.0.1:9099"
"http://127.0.0.1:6108",
"http://127.0.0.1:6108"
],
"labels": {
"alertname": "Fake Alert"