author avatar

akshay

Thu Aug 30 2018

Rails ActionController provides :stale? and :fresh_when methods which can be use to set HTTP_IF_NONE_MATCH and HTTP_IF_MODIFIED_SINCE headers on the browser. This helps the client to check whether the page has been modified. Response freshness is checked by matching Last-Modified and ETag from the server against the client request's HTTP_IF_MODIFIED_SINCE and HTTP_IF_NONE_MATCHheaders. If it matches, then the server responds with 304 (“not modified”) status code. This will make the client to make use of cached copy of the page - thus saving us from the time spent in generating the response.