# Bug with X-Accel-Expires 0?

**URL:** <https://www.ruby-forum.com/t/bug-with-x-accel-expires-0/183662>\
**Category:** NGINX\
**Created:** [February 18, 2010, 11:49am UTC](https://www.ruby-forum.com/t/bug-with-x-accel-expires-0/183662 "2010-02-18T11:49:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSSSSrSSSSme\_Loyet](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee59a6/32.png) [@JSSSSrSSSSme\_Loyet](https://www.ruby-forum.com/u/JSSSSrSSSSme_Loyet)\
**Post date:** [February 18, 2010, 11:49am UTC](https://www.ruby-forum.com/t/bug-with-x-accel-expires-0/183662/1 "2010-02-18T11:49:11Z")

</div>

Hi,

I have a strange behaviour, I think it’s a bug.

I have set nginx as a frontend to apache using proxy\_pass. I also set  
up proxy\_cache to cache everyhting from the proxy:

log\_format my\_combined ‘$remote\_addr - $remote\_user [$time\_local]  
“$request” $status $body\_bytes\_sent “$http\_referer” “$http\_user\_agent”  
$request\_time $upstream\_cache\_status’;  
server {  
…  
access\_log /var/log/nginx/access my\_combined;  
proxy\_cache cache1;

location / {  
proxy\_cache\_valid any 5m;  
proxy\_pass [http://backend.www](http://backend.www);  
}  
}

To exclude some pages from being cached, I’m adding the  
“X-Accel-Expires: 0” in the response from the backend.It works as  
those pages are marked as MISS in the access log (MISS and HIT when  
X-Accel-Expires is not set).

But, when the page is not cached (with X-Accel-Expires) some headers  
are hidden as if the page was cached.

Here is some example:

The backend set these headers:

Set-Cookie: PHPSESSID=bd01a429e06336b883d36d6633a04917; path=/  
Content-Length: 11

The client receives:  
Content-Length: 11

As the page is cached, the Set-Cookie header is removed.

Then if the backend add the X-Accel-Expires header:

Set-Cookie: PHPSESSID=bd01a429e06336b883d36d6633a04917; path=/  
Content-Length: 11  
X-Accel-Expires: 0

The clients receives:  
Content-Length: 11

The page is not cached (thanks to X-Accel-Expires: 0) but the  
Set-Cookie headers has been removed without any reasons.

This bug exists because the list of headers to remove are set when the  
conf is loaded (ngx\_http\_proxy\_merge\_loc\_conf in  
http/modules/ngx\_http\_proxy\_module.c at line 2256) and it should be  
done dynamicaly for each requests.
