From 283326cc61335ec62692dc550e460bb7e20b13b1 Mon Sep 17 00:00:00 2001 From: claudiob Date: Tue, 6 Jan 2015 12:32:27 -0800 Subject: 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] --- actionpack/lib/action_controller/metal/conditional_get.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller/metal') 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 -- cgit v1.2.3