From 32f7e8a5c5d163a50baa7a84acf47d01fec4bcb2 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Sat, 20 Jun 2020 10:30:44 +0200 Subject: [PATCH] cache headers, redirect to format=html by default --- cmd/qrbill-api/api.go | 14 ++++++-------- go.mod | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/cmd/qrbill-api/api.go b/cmd/qrbill-api/api.go index e475202..8092987 100644 --- a/cmd/qrbill-api/api.go +++ b/cmd/qrbill-api/api.go @@ -134,7 +134,11 @@ func logic() error { debugHTML(w, r, prefix, qrch) } - // TODO: add cache control headers + // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control + // […] this alone is the only directive you need in preventing cached + // responses on modern browsers. + w.Header().Add("Cache-Control", "no-store") + if _, err := io.Copy(w, bytes.NewReader(b)); err != nil { log.Printf("%s %s", prefix, err) return @@ -146,13 +150,7 @@ func logic() error { http.Error(w, "not found", http.StatusNotFound) return } - w.Header().Add("Content-Type", "text/html; charset=utf-8") - // TODO: add explanation for how to construct a URL - // e.g. for usage in filemaker web view - fmt.Fprintf(w, "