cache control header on content endpoint

This commit is contained in:
2026-11-13 13:09:15 -05:00
parent 3f78e3b85b
commit 0f5b85a063
3 changed files with 17 additions and 9 deletions
+6
View File
@@ -310,6 +310,12 @@ func contentHandler(db *gorm.DB, cfg Config) http.HandlerFunc {
defer file.Close()
ttl := 600 // 10 minutes
if upload.ExpiresAt != nil {
ttl = int(*upload.ExpiresAt - now)
}
w.Header().Set("Cache-Control", fmt.Sprintf("public, max-age=%d, must-revalidate", ttl))
w.Header().Set("Content-Type", upload.MIMEType)
w.Header().Set("X-Content-Type-Options", "nosniff")
http.ServeContent(w, r, upload.Filename, time.Unix(upload.CreatedAt, 0), file)