aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-22 20:07:49 -0500
committerFrancesco Rodriguez <lrodriguezsanc@gmail.com>2012-09-22 20:07:49 -0500
commit417aa431eb43a8ecbc7edae2d056edebf4f8792f (patch)
tree7e2992f609b9ba700f1181b53fba511378d4a059 /actionpack
parent191ddf26379670b477bd63bccf8debbe16d20ed9 (diff)
downloadrails-417aa431eb43a8ecbc7edae2d056edebf4f8792f.tar.gz
rails-417aa431eb43a8ecbc7edae2d056edebf4f8792f.tar.bz2
rails-417aa431eb43a8ecbc7edae2d056edebf4f8792f.zip
update AC::ConditionalGet documentation [ci skip]
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/metal/conditional_get.rb58
1 files changed, 31 insertions, 27 deletions
diff --git a/actionpack/lib/action_controller/metal/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb
index 12ef68ff26..3f37a6a618 100644
--- a/actionpack/lib/action_controller/metal/conditional_get.rb
+++ b/actionpack/lib/action_controller/metal/conditional_get.rb
@@ -18,8 +18,6 @@ module ActionController
# may want to add the current user id to be part of the etag to prevent authorized displaying
# of cached pages.
#
- # === Example
- #
# class InvoicesController < ApplicationController
# etag { current_user.try :id }
#
@@ -34,25 +32,28 @@ module ActionController
end
end
- # Sets the etag, last_modified, or both on the response and renders a
+ # Sets the etag, +last_modified+, or both on the response and renders a
# <tt>304 Not Modified</tt> response if the request is already fresh.
#
- # Parameters:
- # * <tt>:etag</tt>
- # * <tt>:last_modified</tt>
- # * <tt>:public</tt> By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches).
+ # === Parameters:
+ #
+ # * <tt>:etag</tt>.
+ # * <tt>:last_modified</tt>.
+ # * <tt>:public</tt> By default the Cache-Control header is private, set this to
+ # +true+ if you want your application to be cachable by other devices (proxy caches).
#
- # Example:
+ # === Example:
#
# def show
# @article = Article.find(params[:id])
- # fresh_when(:etag => @article, :last_modified => @article.created_at, :public => true)
+ # fresh_when(etag: @article, last_modified: @article.created_at, public: true)
# end
#
# This will render the show template if the request isn't sending a matching etag or
# If-Modified-Since header and just a <tt>304 Not Modified</tt> response if there's a match.
#
- # You can also just pass a record where last_modified will be set by calling updated_at and the etag by passing the object itself. Example:
+ # You can also just pass a record where +last_modified+ will be set by calling
+ # +updated_at+ and the etag by passing the object itself.
#
# def show
# @article = Article.find(params[:id])
@@ -81,22 +82,24 @@ module ActionController
head :not_modified if request.fresh?(response)
end
- # Sets the etag and/or last_modified on the response and checks it against
+ # Sets the +etag+ and/or +last_modified+ on the response and checks it against
# the client request. If the request doesn't match the options provided, the
# request is considered stale and should be generated from scratch. Otherwise,
# it's fresh and we don't need to generate anything and a reply of <tt>304 Not Modified</tt> is sent.
#
- # Parameters:
- # * <tt>:etag</tt>
- # * <tt>:last_modified</tt>
- # * <tt>:public</tt> By default the Cache-Control header is private, set this to true if you want your application to be cachable by other devices (proxy caches).
+ # === Parameters:
+ #
+ # * <tt>:etag</tt>.
+ # * <tt>:last_modified</tt>.
+ # * <tt>:public</tt> By default the Cache-Control header is private, set this to
+ # +true+ if you want your application to be cachable by other devices (proxy caches).
#
- # Example:
+ # === Example:
#
# def show
# @article = Article.find(params[:id])
#
- # if stale?(:etag => @article, :last_modified => @article.created_at)
+ # if stale?(etag: @article, last_modified: @article.created_at)
# @statistics = @article.really_expensive_call
# respond_to do |format|
# # all the supported formats
@@ -104,7 +107,8 @@ module ActionController
# end
# end
#
- # You can also just pass a record where last_modified will be set by calling updated_at and the etag by passing the object itself. Example:
+ # You can also just pass a record where +last_modified+ will be set by calling
+ # updated_at and the etag by passing the object itself.
#
# def show
# @article = Article.find(params[:id])
@@ -122,7 +126,7 @@ module ActionController
# def show
# @article = Article.find(params[:id])
#
- # if stale?(@article, :public => true)
+ # if stale?(@article, public: true)
# @statistics = @article.really_expensive_call
# respond_to do |format|
# # all the supported formats
@@ -134,18 +138,18 @@ module ActionController
!request.fresh?(response)
end
- # Sets a HTTP 1.1 Cache-Control header. Defaults to issuing a <tt>private</tt> instruction, so that
- # intermediate caches must not cache the response.
+ # Sets a HTTP 1.1 Cache-Control header. Defaults to issuing a +private+
+ # instruction, so that intermediate caches must not cache the response.
#
# expires_in 20.minutes
- # expires_in 3.hours, :public => true
- # expires_in 3.hours, :public => true, :must_revalidate => true
+ # expires_in 3.hours, public: true
+ # expires_in 3.hours, public: true, must_revalidate: true
#
# This method will overwrite an existing Cache-Control header.
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
#
# The method will also ensure a HTTP Date header for client compatibility.
- def expires_in(seconds, options = {}) #:doc:
+ def expires_in(seconds, options = {})
response.cache_control.merge!(
:max_age => seconds,
:public => options.delete(:public),
@@ -157,9 +161,9 @@ module ActionController
response.date = Time.now unless response.date?
end
- # Sets a HTTP 1.1 Cache-Control header of <tt>no-cache</tt> so no caching should occur by the browser or
- # intermediate caches (like caching proxy servers).
- def expires_now #:doc:
+ # Sets a HTTP 1.1 Cache-Control header of <tt>no-cache</tt> so no caching should
+ # occur by the browser or intermediate caches (like caching proxy servers).
+ def expires_now
response.cache_control.replace(:no_cache => true)
end