Set a short 1 day cache duration until we do something more complex. Closes #131

This commit is contained in:
Gabe Kangas
2020-08-30 16:07:20 -07:00
parent bb25207cd9
commit 351fbe8834
2 changed files with 18 additions and 7 deletions

View File

@@ -2,10 +2,18 @@ package middleware
import (
"net/http"
"strconv"
)
//DisableCache writes the disable cache header on the responses
func DisableCache(w *http.ResponseWriter) {
(*w).Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
(*w).Header().Set("Expires", "0")
func DisableCache(w http.ResponseWriter) {
w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
w.Header().Set("Expires", "0")
}
//SetCache will set the cache control header of a response
func SetCache(days int, w http.ResponseWriter) {
seconds := strconv.Itoa(days * 86400)
w.Header().Set("Cache-Control", "max-age="+seconds)
w.Header().Set("Expires", seconds)
}