summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSean McGivern <sean@gitlab.com>2019-01-22 15:59:45 +0000
committerSean McGivern <sean@gitlab.com>2019-01-22 15:59:45 +0000
commit7363428c0928b14bfd8c85a2a16d0f36622db747 (patch)
treecc8042c9b673a3cefddeff0c64ca91d5bfa92030 /app
parentf02be29e52ceb5622e3182830be833f4dfe7c9ce (diff)
parent2d057da183b35d4b4eca6eda8b005d7d068c342a (diff)
downloadgitlab-ce-7363428c0928b14bfd8c85a2a16d0f36622db747.tar.gz
Merge branch 'tz-user-avatar-caching' into 'master'
Changed the Caching of User Avatars to be public and to 5 minutes See merge request gitlab-org/gitlab-ce!24546
Diffstat (limited to 'app')
-rw-r--r--app/controllers/concerns/uploads_actions.rb12
-rw-r--r--app/controllers/uploads_controller.rb4
2 files changed, 15 insertions, 1 deletions
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb
index c114e16edf8..4ec0e94df9a 100644
--- a/app/controllers/concerns/uploads_actions.rb
+++ b/app/controllers/concerns/uploads_actions.rb
@@ -29,7 +29,13 @@ module UploadsActions
def show
return render_404 unless uploader&.exists?
- expires_in 0.seconds, must_revalidate: true, private: true
+ if cache_publicly?
+ # We need to reset caching from the applications controller to get rid of the no-store value
+ headers['Cache-Control'] = ''
+ expires_in 5.minutes, public: true, must_revalidate: false
+ else
+ expires_in 0.seconds, must_revalidate: true, private: true
+ end
disposition = uploader.image_or_video? ? 'inline' : 'attachment'
@@ -114,6 +120,10 @@ module UploadsActions
nil
end
+ def cache_publicly?
+ false
+ end
+
def model
strong_memoize(:model) { find_model }
end
diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb
index fa5d84633b5..519e7439205 100644
--- a/app/controllers/uploads_controller.rb
+++ b/app/controllers/uploads_controller.rb
@@ -70,6 +70,10 @@ class UploadsController < ApplicationController
end
end
+ def cache_publicly?
+ User === model || Appearance === model
+ end
+
def upload_model_class
MODEL_CLASSES[params[:model]] || raise(UnknownUploadModelError)
end