aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudiob <claudiob@gmail.com>2015-01-06 12:32:27 -0800
committerclaudiob <claudiob@gmail.com>2015-01-06 12:32:27 -0800
commit283326cc61335ec62692dc550e460bb7e20b13b1 (patch)
tree8746e4586518753f026ab3710f6dee4c03409d1a
parent9fe8e19af1db5fe82c83c9af9afc7f59883ee4e4 (diff)
downloadrails-283326cc61335ec62692dc550e460bb7e20b13b1.tar.gz
rails-283326cc61335ec62692dc550e460bb7e20b13b1.tar.bz2
rails-283326cc61335ec62692dc550e460bb7e20b13b1.zip
Better examples for fresh_when and stale?
It is clearer and closer to reality to use `@article.updated_at` as the `:last_modified` parameter of `fresh_when` and `stale?`. Using `@article.created_at` would result in the cache never expiring, since the creation timestamp never changes. [ci skip]
-rw-r--r--actionpack/lib/action_controller/metal/conditional_get.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/conditional_get.rb b/actionpack/lib/action_controller/metal/conditional_get.rb
index b210ee3423..febbc72861 100644
--- a/actionpack/lib/action_controller/metal/conditional_get.rb
+++ b/actionpack/lib/action_controller/metal/conditional_get.rb
@@ -51,7 +51,7 @@ module ActionController
#
# 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.updated_at, public: true)
# end
#
# This will render the show template if the request isn't sending a matching ETag or
@@ -115,7 +115,7 @@ module ActionController
# def show
# @article = Article.find(params[:id])
#
- # if stale?(etag: @article, last_modified: @article.created_at)
+ # if stale?(etag: @article, last_modified: @article.updated_at)
# @statistics = @article.really_expensive_call
# respond_to do |format|
# # all the supported formats