Conversation
- should be done before rendering to save server resources when fresh_when renders head 304 - adds spec to confirm that pages#show does not get called once cached
adarsh
left a comment
There was a problem hiding this comment.
Great catch! My personal preference is not to call before_ or other callbacks, due to a long history of gotcha-type negative interactions. Rather explicitly call the class/method where used, if possible.
|
@adarsh I tried to move the before_action filters into the actions but I discovered that the behavior of filters is quite special in that if you render or redirect in the filter it cancels the action. The |
Reason for Change
set_cache_headersshould really be called before the controller action to save on server resources and increase the cached response speed when it turns out that the website has not been modified as determined by the call tofresh_when. In that case the 304 Not Modified response should go out as soon as possible.Changes
fresh_when renders head 304