0
0
Fork 0

Reduce server load caused by anonymous viewing. (#9059)

Do not start a session if the current user is not logged in for public-facing pages.

Mark pages that don't care about sessions as publicly cacheable.

Keep the max age as 0 so proxies and browsers will still try to retrieve an updated version but can still fall back to the stale version if the site is down or too slow.

Fixes #9035.
This commit is contained in:
Ben Lubar 2019-03-17 09:39:25 -05:00 committed by Eugen Rochko
parent a20354a20b
commit c3d1594576
4 changed files with 17 additions and 2 deletions

View file

@ -151,6 +151,11 @@ class ApplicationController < ActionController::Base
response.headers['Vary'] = 'Accept'
end
def mark_cacheable!
skip_session!
expires_in 0, public: true
end
def skip_session!
request.session_options[:skip] = true
end