module Roda::RodaPlugins::Caching::ResponseMethods

def cache_control(opts)

http://tools.ietf.org/html/rfc2616#section-14.9.1
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
  self['Cache-Control'] = values.join(', ') unless values.empty?
end

def expires(max_age, opts=OPTS)

HTTP 1.0 clients (Cache-Control is an HTTP 1.1 header).
cached for. Also sets the Expires header, useful if you have
be an integer number of seconds that the current request should be
Set Cache-Control header with the max_age given. max_age should
def expires(max_age, opts=OPTS)
  cache_control(Hash[opts].merge!(:max_age=>max_age))
  self['Expires'] = (Time.now + max_age).httpdate
end

def finish

Remove Content-Type and Content-Length for 304 responses.
def finish
  a = super
  if a[0] == 304
    h = a[1]
    h.delete('Content-Type')
    h.delete('Content-Length')
  end
  a
end