Rails http caching: Setting cache-control header not caching (not returning 305 not modified response) http page
<p>I am on Rails 4 and learning http caching from here <a href="https://devcenter.heroku.com/articles/http-caching-ruby-rails" rel="nofollow">https://devcenter.heroku.com/articles/http-caching-ruby-rails</a></p>

<p>I am trying to set cache-control header with rails expires_in method. please see this link <a href="https://devcenter.heroku.com/articles/http-caching-ruby-rails#time-based-cache-headers" rel="nofollow">https://devcenter.heroku.com/articles/http-caching-ruby-rails#time-based-cache-headers</a></p>

<p>i am able to set cache-control value to max-age = 180. however when i refresh my web page again within 180 seconds after previous http request the request is hit to the rails entire stack again. i was expecting rails to return 305 not modified response because the cache-control header max-age value is set to 180 seconds.</p>

<p>Request headers</p>

<pre><code>Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:_demo_app_session=elhZMUpaQkNJRGlwZG00R24vTEpyaWgzWCswckJ3eFU5bGFkM2lleGF3dDZOcnd1YXlyanNhY2lYb1pUTWJIZU4wK1FUNlRKWDh3LzVlamR0eUJrUFJ4c3UveFFyWVNWUHNCVHBGeGtYWTg2MmFmVnFTdU85TG96Vk5UOE5MMXFXWHBQYld0OTIxSFVId3lGZzdPSDVnPT0tLU5FZEhGbkppa0tkL0FQYkRYU0xPTUE9PQ%3D%3D--f8d61e1b9dd668b366e14271ac8412cb2579945a
Host:localhost:3000
If-None-Match:W/"bae944fae4d6e7f37fceeb0e4dd272c8"
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.101 Safari/537.36
Name
Path
</code></pre>

<p>Response headers</p>

<pre><code>Cache-Control:max-age=120, public
Connection:Keep-Alive
Content-Length:3188
Content-Type:text/html; charset=utf-8
Date:Thu, 14 Apr 2016 17:39:08 GMT
Etag:W/"946d51d48e02b01a99af19862d2afc3e"
Server:WEBrick/1.3.1 (Ruby/2.2.1/2015-02-26)
Set-Cookie:_demo_app_session=TjFxZWlrT3hacFhhUEp0SXpTb3drNG9SeWZranV6TFlyc0dtRFpWUDFlRkY3eU90aEJPZTZNUmRlTThxQnF4SUxxM1g5QjVSUUxWYlUrd3NUbGxna0o0bHVMeXVHN0tiNUlSN2hndFE3a0U2Y28yemhzWUgzMWJIWCsyS0t2WFlLSWdmSWNuV0txVVJUYzhMZlA2eGRnPT0tLUhIZ1dHVkVZd05URFY2Y3ArQVBMU2c9PQ%3D%3D--f6bc45cb12c14978ed5df4ea3b136b80cb4cecaf; path=/; HttpOnly
X-Content-Type-Options:nosniff
X-Frame-Options:SAMEORIGIN
X-Request-Id:bafba51d-480e-4597-9c1a-56785fdc4704
X-Runtime:0.013116
X-Xss-Protection:1; mode=block
</code></pre>

<p>Am i missing something here?? </p>