Commit 9fccefcb authored by Tim Zallmann's avatar Tim Zallmann

Reduced the cache settings setup

parent b793f0fa
...@@ -32,15 +32,12 @@ module UploadsActions ...@@ -32,15 +32,12 @@ module UploadsActions
# We need to reset caching from the applications controller to get rid of the no-store value # We need to reset caching from the applications controller to get rid of the no-store value
headers['Cache-Control'] = '' headers['Cache-Control'] = ''
headers['Pragma'] = '' headers['Pragma'] = ''
if cache_publicly?
# Caching for user avatars ttl, directives = *cache_settings
expires_in 5.minutes, public: true, must_revalidate: false ttl ||= 6.months
elsif avatar? directives ||= { private: true, must_revalidate: true }
# Caching for Project + Group Avatars
expires_in 5.minutes, private: true, must_revalidate: true expires_in ttl, directives
else
expires_in 6.months, private: true, must_revalidate: true
end
disposition = uploader.embeddable? ? 'inline' : 'attachment' disposition = uploader.embeddable? ? 'inline' : 'attachment'
...@@ -125,12 +122,8 @@ module UploadsActions ...@@ -125,12 +122,8 @@ module UploadsActions
nil nil
end end
def cache_publicly? def cache_settings
false []
end
def avatar?
false
end end
def model def model
......
...@@ -81,16 +81,13 @@ class UploadsController < ApplicationController ...@@ -81,16 +81,13 @@ class UploadsController < ApplicationController
end end
end end
def cache_publicly? def cache_settings
User === model || Appearance === model case model
end when User, Appearance
[5.minutes, { public: true, must_revalidate: false }]
def avatar? when Project, Group
User === model || Project === model || Group === model [5.minutes, { private: true, must_revalidate: true }]
end end
def note_upload?
Note === model
end end
def secret? def secret?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment