Refactor `Cache-Control` and `Vary` definitions (#24347)
parent
4db8230194
commit
e98c86050a
64 changed files with 424 additions and 173 deletions
@ -1,18 +1,8 @@ |
|||||||
# frozen_string_literal: true |
# frozen_string_literal: true |
||||||
|
|
||||||
class CustomCssController < ApplicationController |
class CustomCssController < ActionController::Base # rubocop:disable Rails/ApplicationController |
||||||
skip_before_action :store_current_location |
|
||||||
skip_before_action :require_functional! |
|
||||||
skip_before_action :update_user_sign_in |
|
||||||
skip_before_action :set_session_activity |
|
||||||
|
|
||||||
skip_around_action :set_locale |
|
||||||
|
|
||||||
before_action :set_cache_headers |
|
||||||
|
|
||||||
def show |
def show |
||||||
expires_in 3.minutes, public: true |
expires_in 3.minutes, public: true |
||||||
request.session_options[:skip] = true |
|
||||||
render content_type: 'text/css' |
render content_type: 'text/css' |
||||||
end |
end |
||||||
end |
end |
||||||
|
@ -0,0 +1,15 @@ |
|||||||
|
# frozen_string_literal: true |
||||||
|
|
||||||
|
module ActionController |
||||||
|
module ConditionalGetExtensions |
||||||
|
def expires_in(*) |
||||||
|
# This backports a fix from Rails 7 so that a more private Cache-Control |
||||||
|
# can be overriden by calling expires_in on a specific controller action |
||||||
|
response.cache_control.delete(:no_store) |
||||||
|
|
||||||
|
super |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
ActionController::ConditionalGet.prepend(ActionController::ConditionalGetExtensions) |
Loading…
Reference in new issue