[performance] Add long cache-control max age to fileserver (#710)

This commit is contained in:
tobi 2022-07-15 13:23:04 +02:00 committed by GitHub
parent 1d5c737bbb
commit 839c4346ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -107,5 +107,11 @@ func (m *FileServer) ServeFile(c *gin.Context) {
return
}
c.DataFromReader(http.StatusOK, content.ContentLength, format, content.Content, nil)
c.DataFromReader(http.StatusOK, content.ContentLength, format, content.Content, map[string]string{
// since we'll never host different files at the same
// URL (bc the ULIDs are generated per piece of media),
// it's sensible and safe to use a long cache here, so
// that clients don't keep fetching files over + over again
"Cache-Control": "max-age=604800",
})
}