Fix user avatar caching on gitlab.com
Currently, on .com we have no caching activated for avatars or other images. We have even the opposite our current caching header response is 0.
GDK + Local installation will give you for user avatars as response header (based on this MR gitlab-org/gitlab-foss!24546 (merged)):
Cache-Control: max-age=300, public
User Avatar on .com - https://assets.gitlab-static.net/uploads/-/system/user/avatar/1149402/avatar.png?width=23 :
cache-control: private, max-age=0
This is in the current situation the worst performance bottleneck for rendering pages on .com. As every avatar and all other images are currently reloaded every time again. On top of this the plan to activate fastly image optimization to also resize images on the fly is blocked due to the bad cache headers as fastly doesn't do any resizing when the image is officially already invalid. Which is the next big factor as we are currently serving up to 200KB even for an avatar which is only 12x12 pixels big.
The same goes for project avatars, screenshots etc. So this is just the start to find at least for user avatars a good solution and then extend it to the next image type, etc. (also project avatars are non-cached at the moment. When user avatars are cached, next step is then to activate image resizing on our CDN.
Research so far
@andrewn did already a production debug session with me and also in production the Rails application is sending the correct headers but after that in another layer its overwritten again.