mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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]
This commit is contained in:
parent
9fe8e19af1
commit
283326cc61
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue