Add no-cache headers

This commit is contained in:
Herman Schaaf
2016-08-17 19:39:24 +08:00
parent 922594e29f
commit c4876285e7
2 changed files with 9 additions and 0 deletions

View File

@@ -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:])
}

View File

@@ -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)
}