module Roda::RodaPlugins::Caching::ResponseMethods
def cache_control(opts)
See RFC 2616 / 14.9 for more on standard cache control directives:
# => Cache-Control: public, max-age=60
response.cache_control public: true, max_age: 60
Options can also contain value directives (:max_age, :s_maxage).
:no_store, :must_revalidate, :proxy_revalidate), with true as the value.
Options can can any non-value directives (:public, :private, :no_cache,
Specify response freshness policy for using the Cache-Control header.
def cache_control(opts) values = [] opts.each do |k, v| next unless v k = k.to_s.tr('_', '-') values << (v == true ? k : "#{k}=#{v}") end @headers[RodaResponseHeaders::CACHE_CONTROL] = values.join(', ') unless values.empty? end