Problems with cache by mime/type

Francis Daly francis at
Fri Nov 30 14:05:08 UTC 2018

On Fri, Nov 30, 2018 at 11:32:39AM -0200, Jorge Pereira wrote:

Hi there,

> I sent the wrong snip. the correct is using
> $upstream_http_content_type as can be seen below. basically, always

$upstream_http_content_type is the http Content-Type header sent by
upstream in response to the request from nginx to upstream.$upstream_http_

At the time that nginx is deciding "should this request be served from
cache or sent to upstream?", $upstream_http_content_type cannot have
a value.

Your $no_cache variable that is used in the proxy_cache_bypass directive
can only usefully be made up of things that are available in the request
from the client to nginx.

> when I use "proxy_cache_bypass  $no_cache;" that impact the value of
> "map $upstream_http_content_type $no_cache".... I didn't understand
> what is the reason. thanks for any suggestions.

When "proxy_cache_bypass" is used, it must find the value of the variable
$no_cache. At that time, $upstream_http_content_type is empty, so $no_cache
maps to 1.

When "proxy_no_cache" is used, it must find the value of the variable
$no_cache. If $no_cache was set to 1 previously, it will keep that
value. If $no_cache was not set previously, nginx will check the map,
and now potentially set $no_cache to 0.

That is why your "proxy_no_cache" sees a different value depending on
whether "proxy_cache_bypass" is commented out or not.

Francis Daly        francis at

More information about the nginx mailing list