Module: SpreeCmCommissioner::ContentCachable

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/concerns/spree_cm_commissioner/content_cachable.rb

Instance Method Summary collapse

Instance Method Details

#max_ageObject



9
10
11
# File 'app/controllers/concerns/spree_cm_commissioner/content_cachable.rb', line 9

def max_age
  ENV.fetch('CONTENT_CACHE_MAX_AGE', '180')
end

#set_cache_control_for_cdnObject



13
14
15
16
17
18
19
20
21
# File 'app/controllers/concerns/spree_cm_commissioner/content_cachable.rb', line 13

def set_cache_control_for_cdn
  return if response.committed?
  return if response.status != 200

  # max-age: browser cache, s-maxage: server cache
  response.headers['Cache-Control'] = "public, max-age=0, s-maxage=#{max_age}"
  response.headers['Pragma'] = 'no-cache' # For older HTTP/1.0 clients
  response.headers['Expires'] = '0'
end