From c4876285e7811f2f2d067adfa20f3e70e71c8e66 Mon Sep 17 00:00:00 2001 From: Herman Schaaf Date: Wed, 17 Aug 2016 19:39:24 +0800 Subject: [PATCH] Add no-cache headers --- handlers/assets.go | 7 +++++++ handlers/badge.go | 2 ++ 2 files changed, 9 insertions(+) diff --git a/handlers/assets.go b/handlers/assets.go index 78c012d..f534305 100644 --- a/handlers/assets.go +++ b/handlers/assets.go @@ -3,11 +3,18 @@ package handlers import ( "log" "net/http" + "strings" ) // AssetsHandler handles serving static files func AssetsHandler(w http.ResponseWriter, r *http.Request) { log.Println("Serving " + r.URL.Path[1:]) + + if strings.HasSuffix(r.URL.Path, ".svg") { + // don't cache badges + w.Header().Set("Cache-control", "no-store, no-cache, must-revalidate") + } + http.ServeFile(w, r, r.URL.Path[1:]) } diff --git a/handlers/badge.go b/handlers/badge.go index 4305008..8063c14 100644 --- a/handlers/badge.go +++ b/handlers/badge.go @@ -68,5 +68,7 @@ func BadgeHandler(w http.ResponseWriter, r *http.Request, repo string, dev bool) return } + w.Header().Set("Cache-control", "no-store, no-cache, must-revalidate") + http.Redirect(w, r, badgeURL(resp.Grade, style, dev), http.StatusTemporaryRedirect) }