Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Merge branch 'dev' into housekeeping/avatar-cache

ulferts944ce28052c0
diff --cc modules/avatars/lib/api/v3/users/user_avatar_api.rb
index d6bd80b02bd,3ead718a53c..6cc2f1f1000
--- a/modules/avatars/lib/api/v3/users/user_avatar_api.rb
+++ b/modules/avatars/lib/api/v3/users/user_avatar_api.rb
@@@ -34,22 -34,9 +34,22 @@@ module AP
helpers ::AvatarHelper
helpers ::API::Helpers::AttachmentRenderer
+ helpers do
+ def set_cache_headers!
+ return if @user == current_user
+
+ # Cache for one day if not the current user
+ expire_in = 60 * 60 * 24
+ header "Cache-Control", "public, max-age=#{expire_in}"
+ header "Expires", CGI.rfc1123_date(Time.now.utc + expire_in)
+ end
+ end
+
get '/avatar' do
+ set_cache_headers!
+
if local_avatar = local_avatar?(@user)
- respond_with_attachment(local_avatar)
+ respond_with_attachment(local_avatar, external_link_expires_in: external_avatar_link_expires_in)
elsif avatar_manager.gravatar_enabled?
redirect build_gravatar_image_url(@user)
else