# Wrong values for $upstream\_response\_time in add\_header?

**URL:** <https://www.ruby-forum.com/t/wrong-values-for-upstream-response-time-in-add-header/219483>\
**Category:** NGINX\
**Created:** [May 4, 2012, 10:20am UTC](https://www.ruby-forum.com/t/wrong-values-for-upstream-response-time-in-add-header/219483 "2012-05-04T10:20:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [May 4, 2012, 10:20am UTC](https://www.ruby-forum.com/t/wrong-values-for-upstream-response-time-in-add-header/219483/1 "2012-05-04T10:20:28Z")

</div>

Hi,

I’m cross-posting this from the forums to the mailinglist in hope for  
getting a reply here. Sorry for that.

I’m using nginx-1.2.0 (plus upstream-fair and headers-more; for  
complete `nginx -V` and `uname -a` please see  
[nginx -V · GitHub](https://gist.github.com/be4a86dbfdae516a4efe)) and I’m really happy  
with that. However I want to add a couple of Headers  
($upstream\_response\_time in this case) to be passed to the Client for  
debugging purposes. So I’ve added `add_header X-AppServer-Response $upstream_response_time;` to my location block where I do all my proxy  
stuff. I’ve got an upstream block where I’ve put in my 3 backend  
servers. All Backends respond very fast during testing.

However there are unreasonable high values within this header  
(X-AppServer-Response: 74768.562 in this case). I’m using access\_log  
to get some more values written to disk as well for central  
monitoring. Within this log all values seem to be ok (for this  
particular request it’s 0.002 to be exact).

I was able to reproduce that behaviour using different backends  
(apache2 and another nginx in this case).

Any Idea what’s going wrong here?

Regards,  
Chris

---

<div class="post-metadata">

**Author:** ![SSChristian\_BSSnnin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/6f9a4e/32.png) [@SSChristian\_BSSnnin](https://www.ruby-forum.com/u/SSChristian_BSSnnin)\
**Post date:** [May 4, 2012, 12:51pm UTC](https://www.ruby-forum.com/t/wrong-values-for-upstream-response-time-in-add-header/219483/2 "2012-05-04T12:51:51Z")

</div>

Hello!

On Fri, May 04, 2012 at 10:19:49AM +0200, Christian Bönning wrote:

> stuff. I’ve got an upstream block where I’ve put in my 3 backend
> 
> Any Idea what’s going wrong here?

The $upstream\_response\_time is only meaningful once response is  
fully got from upstream, and this happens after response headers  
are got (and sent to client). That is, you basically can’t use  
$upstream\_response\_time in add\_header, only in logs.

Maxim D.
