cache control header on content endpoint
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user