bug with X-Accel-Expires 0 ?

Jérôme Loyet jerome at loyet.net
Thu Feb 18 13:48:21 MSK 2010


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;
  }
}

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.



More information about the nginx mailing list