Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to append a header inside nginx that will say something like 'X-Time: 0.06 seconds' which basically will be the time since nginx connected with the client and nginx responded to the client.

Thanks.

share|improve this question
    
To what purpose? Why does this response time have to be sent to the client via HTTP headers? –  alphadogg Oct 14 '11 at 20:14
    
I can see this being very useful for debugging. –  erikcw Oct 14 '11 at 21:14
    
What I meant was: what was the end goal, because response processing time could be had from the logs. Why send it in a header to the client? –  alphadogg Oct 14 '11 at 23:01

2 Answers 2

From official docs: http://nginx.org/en/docs/http/ngx_http_core_module.html#var_request_time

$request_time request processing time in seconds with a milliseconds resolution (1.3.9, 1.2.6); time elapsed since the first bytes were read from the client

Since versions 1.3.9 and 1.2.6 in common variables. Before: only in ngx_http_log_module.

share|improve this answer

AFAIK, the short answer is you cannot. Nginx don't understand the $request_time variable if you use something like this:

add_header  X-Time '$request_time';
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.