module Sinatra::Helpers
def expires(amount, *values)
=> Expires: Mon, 08 Jun 2009 08:50:17 GMT
=> Cache-Control: public, must-revalidate, max-age=60
expires 500, :public, :must_revalidate
"values" arguments are passed to the #cache_control helper:
indicating when the response should be considered "stale". The remaining
can be an integer number of seconds in the future or a Time object
Set the Expires header and Cache-Control/max-age directive. Amount
def expires(amount, *values) values << {} unless values.last.kind_of?(Hash) if amount.respond_to?(:to_time) max_age = amount.to_time - Time.now time = amount.to_time else max_age = amount time = Time.now + amount end values.last.merge!(:max_age => max_age) cache_control(*values) response['Expires'] = time.httpdate end