Hacker News new | ask | show | jobs
by technoweenie 5757 days ago
Not really, in Rails, you'd do that stuff in a before filter.

(not really, boom, hat trick: http://img.skitch.com/20100908-tpruqq1pqsw3rsyh2ggn5qb7ac.pn...)

1 comments

;)

I'll let the meme die now. Doing it in a before filter would have the same effect -- unnecessarily increasing the latency before the headers are sent to the web browser. Wether the time is spent in a before filter or a controller action, the key is that the time is being spent before the headers are delivered to the browser. If you are trying to minimize the time it takes to return the header, then you'll want to do that before almost anything else.

You can't send the headers unless you know if the person is authorized or not (and other common things you check in the before filters). So yes, this stuff would have to be checked before rendering a view.
I am willing to errantly send a 200 with a js redirect upon auth fail if it means faster load times.