views:

72

answers:

1

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.

+4  A: 

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.

neutrino