Disable cache-control header on nocache tag

This commit is contained in:
Daniele Tonon
2023-07-12 22:11:21 +02:00
parent 2d540b91b4
commit 0cad5a662a
4 changed files with 8 additions and 0 deletions

View File

@@ -31,6 +31,8 @@ func generate(w http.ResponseWriter, r *http.Request) {
}
w.Header().Set("Content-Type", "image/png")
// +build !nocache
w.Header().Set("Cache-Control", "max-age=604800")
if err := png.Encode(w, img); err != nil {

View File

@@ -9,6 +9,8 @@ import (
func proxy(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.URL.Path, ":~", r.Header.Get("user-agent"))
// +build !nocache
w.Header().Set("Cache-Control", "max-age=604800")
src := r.URL.Query().Get("src")

View File

@@ -275,7 +275,9 @@ func render(w http.ResponseWriter, r *http.Request) {
templateMapping[typ] = "other.html"
}
// +build !nocache
w.Header().Set("Cache-Control", "max-age=604800")
if err := tmpl.ExecuteTemplate(w, templateMapping[typ], params); err != nil {
log.Error().Err(err).Msg("error rendering")
return

View File

@@ -67,7 +67,9 @@ func renderRelayPage(w http.ResponseWriter, r *http.Request) {
"lastNotes": renderableLastNotes,
}
// +build !nocache
w.Header().Set("Cache-Control", "max-age=604800")
if err := tmpl.ExecuteTemplate(w, templateMapping["relay"], params); err != nil {
log.Error().Err(err).Msg("error rendering")
return