提交 283326cc 编写于 作者: C claudiob

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]
上级 9fe8e19a
......@@ -51,7 +51,7 @@ def etag(&etagger)
#
# 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 @@ def fresh_when(record_or_options, additional_options = {})
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册