commit 839c4346ad8164cd6082653c20074ee636fb41bd
parent 1d5c737bbb2d9fe0624830591ce622347c84f314
Author: tobi <31960611+tsmethurst@users.noreply.github.com>
Date: Fri, 15 Jul 2022 13:23:04 +0200
[performance] Add long cache-control max age to fileserver (#710)
Diffstat:
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/internal/api/client/fileserver/servefile.go b/internal/api/client/fileserver/servefile.go
@@ -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",
+ })
}