aboutsummaryrefslogtreecommitdiff
path: root/internal/headers.go
blob: fdab2a7b2298e2b6c420af13c76d0c9636ab4466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package internal

import (
	"net/http"

	"within.website/x"
)

func UnchangingCache(h http.Handler) http.Handler {
	if x.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)
	})
}