From 75f43f98373b2ac41946d9b0b37934cae6a86e62 Mon Sep 17 00:00:00 2001 From: Travis Ralston <travpc@gmail.com> Date: Tue, 23 Jul 2019 22:53:55 -0600 Subject: [PATCH] Add some cache control headers Fixes https://github.com/turt2live/matrix-media-repo/issues/185 --- api/webserver/route_handler.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/webserver/route_handler.go b/api/webserver/route_handler.go index 17468015..c3983d0a 100644 --- a/api/webserver/route_handler.go +++ b/api/webserver/route_handler.go @@ -122,6 +122,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { "method": r.Method, "statusCode": strconv.Itoa(http.StatusOK), }).Inc() + w.Header().Set("Cache-Control", "private, max-age=259200") // 3 days w.Header().Set("Content-Type", result.ContentType) if result.SizeBytes > 0 { w.Header().Set("Content-Length", fmt.Sprint(result.SizeBytes)) @@ -143,6 +144,7 @@ func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { "method": r.Method, "statusCode": strconv.Itoa(http.StatusOK), }).Inc() + w.Header().Set("Cache-Control", "private, max-age=604800") // 7 days w.Header().Set("Content-Type", "image/png") io.Copy(w, result.Avatar) return // Prevent sending conflicting responses -- GitLab