Cache by mime type

Francis Daly francis at
Sun Jul 22 18:12:24 UTC 2012

On Sun, Jul 22, 2012 at 05:27:44AM -0400, burn wrote:

Hi there,

> Thanks, that seems to work. But I still don't quite understand how. I
> did use both directives with the same variable. Now when I set
> "proxy_cache_bypass 0;", it seems to correctly cache images and serve
> that cache.

proxy_cache_bypass is "shall I serve this from upstream, even if I
already have a valid cached version". Setting it to 0 (or empty) means
that everything that is valid in the cache, will be served from the cache.

Strictly, it shouldn't be used in this case at all. But it is needed
to hush the warning that is presumably due to the bug mentioned in

(I think that that bug was fixed in 1.0.3; possibly the warning is no
longer needed?)

And now you are using proxy_cache_bypass without an identical
proxy_no_cache -- although you're not actually caring about the
proxy_cache_bypass part, so maybe you won't have the problems referred to.

> I'd imagine that unconditional 0 in that directive would
> cause nothing being served from cache ever (as that variable is
> considered first).

No, unconditional 0 there means "serve from cache if possible", and is
equivalent to the line being omitted.

proxy_no_cache is about "shall I actually save this response into the
cache, even though all other indications are that I should do so". That's
the one that you want to be "no, don't" for all of the mime types that
you don't want cached.

All the best,

Francis Daly        francis at

More information about the nginx mailing list