Turned cache_privately? into cache_publicly?

Also removed unnecessary comment
This commit is contained in:
Tim Zallmann 2019-01-22 11:09:04 +01:00
parent 86cda964cf
commit 2d057da183
3 changed files with 7 additions and 8 deletions

View File

@ -29,12 +29,12 @@ module UploadsActions
def show
return render_404 unless uploader&.exists?
if cache_privately?
expires_in 0.seconds, must_revalidate: true, private: true
else
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'
@ -120,8 +120,8 @@ module UploadsActions
nil
end
def cache_privately?
true
def cache_publicly?
false
end
def model

View File

@ -70,8 +70,8 @@ class UploadsController < ApplicationController
end
end
def cache_privately?
true unless User === model || Appearance === model
def cache_publicly?
User === model || Appearance === model
end
def upload_model_class

View File

@ -14,7 +14,6 @@ end
shared_examples 'content publicly cached' do
it 'ensures content is publicly cached' do
# Fixed in newer versions of ActivePack, it will only output a single `private`.
expect(subject['Cache-Control']).to eq('max-age=300, public')
end
end