Nginx cache-control headers issue

Francis Daly francis at
Fri Jul 19 22:47:15 UTC 2019

On Thu, Jul 18, 2019 at 06:44:13PM -0400, andregr-jp wrote:

Hi there,

> I have an nginx proxy which suddenly adding 2 cache-control headers and the
> last modified time is always the current time:

I suspect that whatever is being reverse-proxied changed recently to
send these headers.

>            #Add Headers
>            add_header             Cache-Control 'public max-age=31536000
> s-maxage=31536000';

add_header is "please send this in the nginx response, as well as
everything else".

>            proxy_hide_header      x-amz-id-2;

proxy_hide_header is "please do not send this, from upstream to the

>    proxy_ignore_headers   Cache-Control;

proxy_ignore_headers is "don't use these special headers".

> I don't know why is adding this control header: Cache-Control: private,
> max-age=3600, max-stale=0

You probably want to add "proxy_hide_header Cache-Control"; or to change
back whatever changed on your upstream which made it claim that things
are public.

You can look at the response from upstream (e.g.,
$upstream_http_cache_control) to confirm whether the header is set there.

Francis Daly        francis at

More information about the nginx mailing list