Showing response time in a rails app
I want to display a This page took x seconds
widget at the bottom of every page in my rails application. I would like x
to reflect the approximate amount of time the request spent on my server. What is a good way of doing this?
Edit: My production server is on phusion passenger and development environment on mongerel. Would love to have a solution that works well with both.
Update:开发者_运维知识库 I think for the purpose of this question, the railscast solution is a bit overboard. I modified the middleware suggested in there to just set up a constant and used that in my layout. This way I won't have to change any content-length headers. Thanks again neutrino. Rack middleware are very interesting.
First I thought, that's a good use for a rack middleware. Then I thought uh, Ryan has got one on this. Then voila, a railscast on how to measure the response time via rack middleware :)
Obviously works with both mongrel and passenger.
精彩评论