diff options
author | 2022-07-15 13:23:04 +0200 | |
---|---|---|
committer | 2022-07-15 13:23:04 +0200 | |
commit | 839c4346ad8164cd6082653c20074ee636fb41bd (patch) | |
tree | f7b648e6b101ed4e8d8da847038f648f70df7492 /internal/api/client/fileserver | |
parent | [bugfix] Fix profile card display issues on smaller screens w/responsive quer... (diff) | |
download | gotosocial-839c4346ad8164cd6082653c20074ee636fb41bd.tar.xz |
[performance] Add long cache-control max age to fileserver (#710)
Diffstat (limited to 'internal/api/client/fileserver')
-rw-r--r-- | internal/api/client/fileserver/servefile.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/api/client/fileserver/servefile.go b/internal/api/client/fileserver/servefile.go index ee2ff51ad..ac2fa7bc2 100644 --- 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", + }) } |