FIX: properly specify default on no cache on all resources

This commit is contained in:
Sam 2016-11-15 17:00:28 +11:00
parent 5613c5f81a
commit 63d9d4f301
3 changed files with 9 additions and 0 deletions

View File

@ -45,6 +45,7 @@ class ApplicationController < ActionController::Base
before_filter :check_xhr
after_filter :add_readonly_header
after_filter :perform_refresh_session
after_filter :dont_cache_page
layout :set_layout
@ -64,6 +65,12 @@ class ApplicationController < ActionController::Base
refresh_session(current_user)
end
def dont_cache_page
if !response.headers["Cache-Control"] && response.cache_control.blank?
response.headers["Cache-Control"] = "no-store, must-revalidate, no-cache, private"
end
end
def slow_platform?
request.user_agent =~ /Android/
end

View File

@ -529,6 +529,7 @@ describe TopicsController do
get :show, topic_id: topic.id, slug: topic.slug
expect(response).to be_success
expect(css_select("link[rel=canonical]").length).to eq(1)
expect(response.headers["Cache-Control"]).to eq("no-store, must-revalidate, no-cache, private")
end
end

View File

@ -46,6 +46,7 @@ describe UserAvatarsController do
get :show, size: 98, username: user.username, version: upload.id, hostname: 'default'
expect(response.body).to eq("image")
expect(response.headers["Cache-Control"]).to eq('max-age=31557600, public')
end
it 'serves image even if size missing and its in local mode' do