Fix Vary parsing in cache control enforcement (#37426)
This commit is contained in:
parent
b35b3a8bcc
commit
b55982cc1a
@ -19,7 +19,7 @@ module CacheConcern
|
|||||||
# from being used as cache keys, while allowing to `Vary` on them (to not serve
|
# from being used as cache keys, while allowing to `Vary` on them (to not serve
|
||||||
# anonymous cached data to authenticated requests when authentication matters)
|
# anonymous cached data to authenticated requests when authentication matters)
|
||||||
def enforce_cache_control!
|
def enforce_cache_control!
|
||||||
vary = response.headers['Vary']&.split&.map { |x| x.strip.downcase }
|
vary = response.headers['Vary'].to_s.split(',').map { |x| x.strip.downcase }.reject(&:empty?)
|
||||||
return unless vary.present? && %w(cookie authorization signature).any? { |header| vary.include?(header) && request.headers[header].present? }
|
return unless vary.present? && %w(cookie authorization signature).any? { |header| vary.include?(header) && request.headers[header].present? }
|
||||||
|
|
||||||
response.cache_control.replace(private: true, no_store: true)
|
response.cache_control.replace(private: true, no_store: true)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user