mirror of
https://github.com/gojp/goreportcard.git
synced 2026-01-29 06:49:05 +08:00
Add no-cache headers
This commit is contained in:
@@ -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:])
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user