instance method
expires_in
Ruby on Rails 2.2.3
Since v2.2.3 Last seen in v2.3.18Available in: v2.2.3 v2.3.18
Signature
expires_in(seconds, options = {})
Sets a HTTP 1.1 Cache-Control header. Defaults to issuing a “private” instruction, so that intermediate caches shouldn’t cache the response.
Examples:
expires_in 20.minutes expires_in 3.hours, :private => false expires in 3.hours, 'max-stale' => 5.hours, :private => nil, :public => true
This method will overwrite an existing Cache-Control header. See www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
Parameters
-
secondsreq -
optionsopt = {}
Source
# File actionpack/lib/action_controller/base.rb, line 1150
def expires_in(seconds, options = {}) #:doc:
cache_options = { 'max-age' => seconds, 'private' => true }.symbolize_keys.merge!(options.symbolize_keys)
cache_options.delete_if { |k,v| v.nil? or v == false }
cache_control = cache_options.map{ |k,v| v == true ? k.to_s : "#{k.to_s}=#{v.to_s}"}
response.headers["Cache-Control"] = cache_control.join(', ')
end
Defined in actionpack/lib/action_controller/base.rb line 1150
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Base