proxy_ignore_headers doesn't seem to work

Maxim Dounin mdounin at
Thu Jan 5 03:18:57 UTC 2012


On Wed, Jan 04, 2012 at 03:12:10PM -0500, piotr wrote:

> Maxim,
> Sorry for the late response.
> I'm trying to hide those headers, you can see it in config posted
> before:
> proxy_ignore_headers X-Accel-Expires Expires Cache-Control Set-Cookie;
> proxy_cache_valid 200 302 600h;
> proxy_cache_valid any 90m;
> But as you can see, you can find expire, cache-control headers in proxy
> repsonse, and also in headers of stored cache files on disk. With values
> from upstream server, not those set in config.

You don't hide the headers, and don't set headers in config.  The 
proxy_ignore_headers instruct nginx to ignore headers in question 
(i.e. don't set/limit cache validity time as stored in cache 
metadata based on these headers).  The proxy_cache_valid 
directives set cache validity times.  None of these directives 
hide or modify headers in question.

To hide headers, you have to use the proxy_hide_header directive 
(as already suggested in previous message), see here for details:

To explicitly set Cache-Control/Expires headers, use the "expires" 
directive, see here for details:

(no official docs in English yet)

> I'm not sure now those times from my previous response, but whatever i
> do (delete cached files from disk, restart nginx, wait 10 minutes to
> expire files cached on disk), nginx is always returning in response
> cache-control and expire in 600 sec - taking this value from upstream
> server, not from the config file. Also, file is stored on disk for 600s,
> after this time i can see in logs that nginx is downloading again file
> from upstream server. Nginx should cache files for 600h in current
> config, but i've also tried before other values, like 6h or 6d etc.

Do you request the file in question with interval larger than 600 
seconds, without any intermediate requests?  It is expected to be 
removed from cache as inactive one in such test, see desciption of 
the "inactive" parameter of the "proxy_cache_path" directive here:

Try requesting a file once per minute to keep it active.

Maxim Dounin

More information about the nginx mailing list