blob: 47aa2ccb7d1959f132277db390bda1ac6607ecfc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
package internal
import (
"net/http"
"github.com/TecharoHQ/anubis"
)
// UnchangingCache sets the Cache-Control header to cache a response for 1 year if
// and only if the application is compiled in "release" mode by Docker.
func UnchangingCache(h http.Handler) http.Handler {
if anubis.Version == "devel" {
return h
}
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Cache-Control", "public, max-age=31536000")
h.ServeHTTP(w, r)
})
}
|