Method deprecated or moved
This method is deprecated or moved on the latest stable version.
The last existing version (v2.3.8) is shown here.
expires_in(seconds, options = {})
protected
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, :public => true
expires in 3.hours, 'max-stale' => 5.hours, :public => true
This method will overwrite an existing Cache-Control header. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
for more possibilities.
# File actionpack/lib/action_controller/base.rb, line 1216
def expires_in(seconds, options = {}) #:doc:
cache_control = response.headers["Cache-Control"].split(",").map {|k| k.strip }
cache_control << "max-age=#{seconds}"
cache_control.delete("no-cache")
if options[:public]
cache_control.delete("private")
cache_control << "public"
else
cache_control << "private"
end
# This allows for additional headers to be passed through like 'max-stale' => 5.hours
cache_control += options.symbolize_keys.reject{|k,v| k == :public || k == :private }.map{ |k,v| v == true ? k.to_s : "#{k.to_s}=#{v.to_s}"}
response.headers["Cache-Control"] = cache_control.join(', ')
end