Skip to content

Commit 1d2bf82

Browse files
authored
api: don't cache 404 responses (#71)
1 parent e40286f commit 1d2bf82

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

api/api.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ func (s *Server) sendJSONError(
179179
customMessage string,
180180
) {
181181
w.Header().Set("Content-Type", "application/json")
182+
if code == http.StatusNotFound && w.Header().Get("Cache-Control") == "" {
183+
w.Header().Set("Cache-Control", "no-cache, max-age=0, must-revalidate")
184+
}
185+
186+
// all headers need to be set before this line
182187
w.WriteHeader(code)
183188

184189
if err != nil {

0 commit comments

Comments
 (0)