Open jonsgreen opened 2 years ago
@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 set_cache_headers
calls fresh_when
which renders head :not_modified when fresh and the whole point is to cancel the action in those cases. I am sure there is some way to work around this but my guess is that you did not foresee that this would not be a trivial change to move the filters into the controller actions. Let me know if you want to discuss.
Reason for Change
set_cache_headers
should 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