ruby-china 源码里有很多例子
fresh_when 传进去的是数组的话 就没有last-modified 只有etag, 如果传进去的是object的话就会有etag和last-modified
vagrant@precise64:~/data/ruby-china$ curl -I http://localhost:3000/posts/1
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Etag: "8971c3ad3d341d4a702395429af9f1ca"
Content-Type: text/html; charset=utf-8
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: ba4f1d1b-cc91-42b1-990d-b3bd703074a1
X-Runtime: 0.416065
Server: WEBrick/1.3.1 (Ruby/2.2.3/2015-08-18)
Date: Sun, 17 Jul 2016 06:49:57 GMT
Content-Length: 0
Connection: Keep-Alive
Set-Cookie: _dirty_session=ZzF2bUQvNGE4NDlXL0dlZVdkc1ZWUElkUExqMWhaNkR0NzhLd3Z4dmhQL2ljdnBNZ3NCMitKMmhqRHRIRlpWL1N2NzBpMFBqVXI1Q1BobEJEVTlydC9QMnZ5bWNLa2NhN0NUQjhhclpTRTZubm5DVU1vKzBkakVQZ0JwMitqUDRTemo0ZU0xaUdHNit6WkExQ1dBcS9RPT0tLWZvc2pmdmExQU1jcDBYbXNoTXFaa1E9PQ%3D%3D--70ba10f3ec4ea22406657cff731ac69a70d90649; path=/; HttpOnly
vagrant@precise64:~/data/ruby-china$ curl -I http://localhost:3000/posts/1
HTTP/1.1 200 OK
X-Frame-Options: SAMEORIGIN
X-Xss-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Etag: "0f7e00167e1fc658e5c40635e5fbfd3f"
Last-Modified: Sun, 17 Jul 2016 04:39:29 GMT
Content-Type: text/html; charset=utf-8
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: 2c53f950-7418-4138-a0e5-6a596e6ce9dd
X-Runtime: 1.389973
Server: WEBrick/1.3.1 (Ruby/2.2.3/2015-08-18)
Date: Sun, 17 Jul 2016 06:50:27 GMT
Content-Length: 0
Connection: Keep-Alive
Set-Cookie: _dirty_session=ZUZLZlBhSDRoTDhRV3lrSmw3bmN0THBDbDIwRHJsbXpmbVZTRmdYVjQwSlNZbmluVTIwYlpoZXN6N2NsL2Yyem16alh0bzRTeEQwSUFEbnViRWpFWUFjWmpLRkhDaTgwWWdHNC8zZ21GK3RxVkVtV3dkVnQwRkVnb1RJWkNZNTYyQWZHMDdDM3RlbHFOLy9aYW43RDlRPT0tLTVwVkNHOHovZlVpdVdIT3dkNXkrY0E9PQ%3D%3D--c58910d04ef58c51f06c7d48f3045d985e8b25ac; path=/; HttpOnly
last-modified取得是updated_at
2.2.3 :001 > a = Post.first
Post Load (3.1ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
=> #<Post id: 1, title: "lalala", body: "just a test", created_at: "2016-07-17 04:39:29", updated_at: "2016-07-17 04:39:29">
2.2.3 :002 > [a,a].try(:updated_at)
=> nil