# Nginx ignores proxy\_ignore\_headers

**URL:** <https://www.ruby-forum.com/t/nginx-ignores-proxy-ignore-headers/203556>\
**Category:** NGINX\
**Created:** [February 22, 2011, 9:37pm UTC](https://www.ruby-forum.com/t/nginx-ignores-proxy-ignore-headers/203556 "2011-02-22T21:37:17Z")\
**Posts on this page:** 5\
**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:** [February 22, 2011, 9:37pm UTC](https://www.ruby-forum.com/t/nginx-ignores-proxy-ignore-headers/203556/1 "2011-02-22T21:37:17Z")

</div>

I am running nginx 0.8.54 on CentOS 5.2,  
In nginx.conf I have set  
proxy\_ignore\_headers Expires Cache-Control X-Accel-Expires;

but still I get bunch of misses because of expire date.  
For example:  
\*\*\*22/Feb/2011:21:31:39 +0100 MISS Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /opensearch HTTP/1.1” (200)  
\*\*\*22/Feb/2011:21:31:40 +0100 MISS Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /opensearch HTTP/1.1” (200)  
\*\*\*22/Feb/2011:21:31:43 +0100 MISS Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /opensearch HTTP/1.1” (200)  
\*\*\*22/Feb/2011:21:31:47 +0100 MISS Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /opensearch HTTP/1.1” (200)

Similarly:  
\*\*\*22/Feb/2011:21:33:52 +0100 EXPIRED Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /xxxxx/xxxxx HTTP/1.1” (200)  
\*\*\*22/Feb/2011:21:33:52 +0100 EXPIRED Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /xxxxx/xxxxx HTTP/1.1” (200)  
\*\*\*22/Feb/2011:21:33:53 +0100 EXPIRED Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /xxxxx/xxxxx HTTP/1.1” (200)

Any idea why that happens?

D

Posted at Nginx Forum:

> **[nginx ignores proxy\_ignore\_headers](https://forum.nginx.org/read.php?2,177542,177542#msg-177542)**
>
> I am running nginx 0.8.54 on CentOS 5.2, In nginx.conf I have set proxy\_ignore\_headers Expires Cache-Control X-Accel-Expires; but still I get bunch of misses because of expire date. For example: \*\*\*22/Feb/2011:21:31:39 +0100 MISS Cache-Control:...

---

<div class="post-metadata">

**Author:** ![VRider](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/87869e/32.png) [@VRider](https://www.ruby-forum.com/u/VRider)\
**Post date:** [February 23, 2011, 5:12pm UTC](https://www.ruby-forum.com/t/nginx-ignores-proxy-ignore-headers/203556/2 "2011-02-23T17:12:23Z")

</div>

I did additional research.

It looks like it is not about Expire date. I created one simple PHP  
script to mimic the same headers to see if there will be any  
difference.

This is what I got:  
\*\*\*23/Feb/2011:16:35:56 +0100 MISS Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /test2.php HTTP/1.0” (200) “Wget/1.11.4 Red Hat  
modified”  
\*\*\*23/Feb/2011:16:35:57 +0100 HIT Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /test2.php HTTP/1.0” (200) “Wget/1.11.4 Red Hat  
modified”  
\*\*\*23/Feb/2011:16:36:02 +0100 MISS Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /opensearch HTTP/1.0” (200) “Wget/1.11.4 Red Hat  
modified”  
\*\*\*23/Feb/2011:16:36:03 +0100 MISS Cache-Control: no-store, no-cache,  
must-revalidate, post-check=0, pre-check=0 Expires: Thu, 19 Nov 1981  
08:52:00 GMT “GET /opensearch HTTP/1.0” (200) “Wget/1.11.4 Red Hat  
modified”

With same expire date, first request is cached and the second is not.  
These are full headers:  
Server: nginx/0.8.53  
Date: Wed, 23 Feb 2011 15:35:56 GMT  
Content-Type: text/html; charset=UTF-8  
Connection: keep-alive  
X-Powered-By: PHP/5.3.5  
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,  
pre-check=0  
Expires: Thu, 19 Nov 1981 08:52:00 GMT  
Pragma: no-cache  
Content-Length: 23

HTTP/1.1 200 OK  
Server: nginx/0.8.53  
Date: Wed, 23 Feb 2011 15:36:02 GMT  
Content-Type: text/xml; charset=UTF-8  
Connection: keep-alive  
X-Powered-By: PHP/5.3.5  
Set-Cookie: SomeSessionId=nlt391qunv2prlpogjc6fne4o4; path=/;  
[domain=.some.domain.com](http://domain=.some.domain.com).  
Expires: Thu, 19 Nov 1981 08:52:00 GMT  
Cache-Control: no-store, no-cache, must-revalidate, post-check=0,  
pre-check=0  
Pragma: no-cache  
Content-Length: 1429

Only difference is that second request (the one that is not cached) had  
Set-Cookie, but I don’t use cookie in proxy\_cache\_key.  
proxy\_cache\_key “$host$request\_uri”;

What am I missing?

D

Posted at Nginx Forum:

> **[Re: nginx ignores proxy\_ignore\_headers](https://forum.nginx.org/read.php?2,177542,177725#msg-177725)**
>
> I am running nginx 0.8.54 on CentOS 5.2, In nginx.conf I have set proxy\_ignore\_headers Expires Cache-Control X-Accel-Expires; but still I get bunch of misses because of expire date. For example: \*\*\*22/Feb/2011:21:31:39 +0100 MISS Cache-Control:...

---

<div class="post-metadata">

**Author:** ![VRider](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/87869e/32.png) [@VRider](https://www.ruby-forum.com/u/VRider)\
**Post date:** [February 24, 2011, 11:01am UTC](https://www.ruby-forum.com/t/nginx-ignores-proxy-ignore-headers/203556/3 "2011-02-24T11:01:08Z")

</div>

Hello!

On Wed, Feb 23, 2011 at 11:10:23AM -0500, VRider wrote:

[…]

> Only difference is that second request (the one that is not cached) had  
> Set-Cookie, but I don’t use cookie in proxy\_cache\_key.  
> proxy\_cache\_key “$host$request\_uri”;
> 
> What am I missing?

Changes with nginx 0.8.44:

```
*) Change: now nginx does not cache by default backend responses, if
   they have a "Set-Cookie" header line.

```

Maxim D.

---

<div class="post-metadata">

**Author:** ![VRider](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/87869e/32.png) [@VRider](https://www.ruby-forum.com/u/VRider)\
**Post date:** [February 24, 2011, 12:22pm UTC](https://www.ruby-forum.com/t/nginx-ignores-proxy-ignore-headers/203556/4 "2011-02-24T12:22:23Z")

</div>

Thank you, Maxim, that explains a lot! Is there any option to ignore  
cookies?

D

Posted at Nginx Forum:

> **[Re: nginx ignores proxy\_ignore\_headers](https://forum.nginx.org/read.php?2,177542,177965#msg-177965)**
>
> I am running nginx 0.8.54 on CentOS 5.2, In nginx.conf I have set proxy\_ignore\_headers Expires Cache-Control X-Accel-Expires; but still I get bunch of misses because of expire date. For example: \*\*\*22/Feb/2011:21:31:39 +0100 MISS Cache-Control:...

---

<div class="post-metadata">

**Author:** ![VRider](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/87869e/32.png) [@VRider](https://www.ruby-forum.com/u/VRider)\
**Post date:** [February 24, 2011, 1:03pm UTC](https://www.ruby-forum.com/t/nginx-ignores-proxy-ignore-headers/203556/5 "2011-02-24T13:03:47Z")

</div>

Found! 🙂  
proxy\_ignore\_headers Set-Cookie;

Thank you for your help, Maxim!

Posted at Nginx Forum:

> **[Re: nginx ignores proxy\_ignore\_headers](https://forum.nginx.org/read.php?2,177542,177973#msg-177973)**
>
> I am running nginx 0.8.54 on CentOS 5.2, In nginx.conf I have set proxy\_ignore\_headers Expires Cache-Control X-Accel-Expires; but still I get bunch of misses because of expire date. For example: \*\*\*22/Feb/2011:21:31:39 +0100 MISS Cache-Control:...
