# Adding Hit/Miss header to proxied requests

**URL:** <https://www.ruby-forum.com/t/adding-hit-miss-header-to-proxied-requests/211096>\
**Category:** NGINX\
**Created:** [August 25, 2011, 4:57pm UTC](https://www.ruby-forum.com/t/adding-hit-miss-header-to-proxied-requests/211096 "2011-08-25T16:57:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [August 25, 2011, 4:57pm UTC](https://www.ruby-forum.com/t/adding-hit-miss-header-to-proxied-requests/211096/1 "2011-08-25T16:57:13Z")

</div>

Hi,

We’re using a pretty simple setup of ipvsadm balancing between 6 nginx  
caching-proxies with 3 nginx backend servers configured.

When the request hits the proxy, I add a header to show which proxy  
serviced the request. Similarly the backend servers add a header to  
their response to show which one served the traffic.

Because we’re anycasting the service at three locations, this  
information is very useful for troubleshooting!

Anyway, what I want to do now is add a header to show whether a response  
was served from cache or from the backend. Having been through the  
documentation I’m not currently able to see how this could be done.  
Anyone able to offer any advice?

h6edcgdp6:~ # nginx -v  
nginx: nginx version: nginx/1.1.0

HTTP request sent, awaiting response…  
HTTP/1.1 200 OK  
Server: nginx  
Date: Thu, 25 Aug 2011 13:49:34 GMT  
Content-Type: application/octet-stream  
Connection: keep-alive  
Keep-Alive: timeout=1  
Content-Length: 104857600  
Last-Modified: Fri, 02 Oct 2009 15:24:44 GMT  
**X-CCACDN-Mirror-ID: fsedcgdown1**  
\*\*X-CCACDN-Proxy-ID: fsedcgdp1((  
Accept-Ranges: bytes  
Length: 104857600 (100M) [application/octet-stream]  
Saving to: /dev/null

Cheers

---

<div class="post-metadata">

**Author:** ![Dave\_Barton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@Dave\_Barton](https://www.ruby-forum.com/u/Dave_Barton)\
**Post date:** [August 25, 2011, 5:15pm UTC](https://www.ruby-forum.com/t/adding-hit-miss-header-to-proxied-requests/211096/2 "2011-08-25T17:15:08Z")

</div>

Hello!

On Thu, Aug 25, 2011 at 03:56:34PM +0100, Dave Barton wrote:

> information is very useful for troubleshooting!
> 
> Anyway, what I want to do now is add a header to show whether a response  
> was served from cache or from the backend. Having been through the  
> documentation I’m not currently able to see how this could be done.  
> Anyone able to offer any advice?

add\_header X-Cached $upstream\_cache\_status;

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

Maxim D.

---

<div class="post-metadata">

**Author:** ![Dave\_Barton](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ecc23a/32.png) [@Dave\_Barton](https://www.ruby-forum.com/u/Dave_Barton)\
**Post date:** [August 26, 2011, 10:23am UTC](https://www.ruby-forum.com/t/adding-hit-miss-header-to-proxied-requests/211096/3 "2011-08-26T10:23:13Z")

</div>

Hi Maxim,

No idea how I missed that! Thanks for the help.

Cheers

Dave Barton  
Senior Infrastructure Architect  
Comodo CA Ltd
