Error occurred when fetching sidebar data
PageLayoutHelper#page_image uses Git to retrieve project images but this is not cached and rather slow
The method PageLayoutHelper#page_image
is used to grab a logo from the Git repository to use in OpenGraph/Twitter meta tags. Unless a project has an avatar set via the web UI this method ends up calling Project#avatar_in_git
which tries to figure out what the avatar is from the Git repository, it does this by checking if any of these files exists:
- logo.png
- logo.jpg
- logo.gif
The Git operations are not cached meaning that for projects without an avatar every request ends up triggering a Git operation. Thinking of it we should probably do the following:
- Cache the output of
Project#avatar_in_git
in Redis - Flush this cache whenever a commit is pushed that modifies any of the possible avatar images (but only when the commit actually contains any of these files in the diff stat)