Welcome! Log In Create A New Profile

Advanced

Re: proxy_ignore_headers doesn't seem to work

Francis Daly
January 04, 2012 05:28PM
On Wed, Jan 04, 2012 at 03:12:10PM -0500, piotr wrote:

Hi there,

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

No, that's proxy_ignore_headers, not proxy_hide_header.

> 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.

What comes from upstream is stored on disk. That's expected.

proxy_ignore_headers determines which of upstream headers or
proxy_cache_valid is used by nginx to decide for how long nginx will
cache the response.

Separate from that, you can use "proxy_hide_header" to tell nginx not to
send some headers that came from upstream, to the client.

Separate from that (mostly), you can use "expires" to tell nginx how to
set Expires: and Cache-Control: headers in the response to the client.

"(mostly)" is there because nginx will only send a single Expires header,
so if you use "expires" to set one, then the one from upstream will not
go to the client, even if it isn't in "proxy_hide_header".

> 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.

That is as expected, since you have no other value in the config file
to send in the response, and you have nothing in the config file to tell
nginx not to send what came from upstream.

> 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.

That observation, I don't understand.

You can examine the first few bytes of the on-disk cache file to see
when nginx thinks that it will become stale:

od -t dL $cache_file | head -n 1

The second and fourth numbers there are valid-until- and fetched-at-
timestamps, respectively. So if they are only 600 apart, then something
unexpected (to me) is happening.

When I use configuration like

> proxy_cache_valid 200 302 600h;
> proxy_cache_valid any 90m;

in 1.1.11, I see them being the expected 2160000 (seconds, = 600 hours)
apart for a http 200 response.

Good luck,

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

proxy_ignore_headers doesn't seem to work

piotr December 14, 2011 11:34AM

Re: proxy_ignore_headers doesn't seem to work

Maxim Dounin December 14, 2011 12:10PM

Re: proxy_ignore_headers doesn't seem to work

piotr December 16, 2011 09:11AM

Re: proxy_ignore_headers doesn't seem to work

Maxim Dounin December 18, 2011 06:18AM

Re: proxy_ignore_headers doesn't seem to work

piotr January 04, 2012 03:12PM

Re: proxy_ignore_headers doesn't seem to work

Francis Daly January 04, 2012 05:28PM

Re: proxy_ignore_headers doesn't seem to work

Francis Daly January 04, 2012 06:14PM

Re: proxy_ignore_headers doesn't seem to work

Maxim Dounin January 04, 2012 10:20PM

Re: proxy_ignore_headers doesn't seem to work

piotr January 09, 2012 01:50PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 200
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready