On Tue, Nov 01, 2022 at 10:07:37PM +0000, Francis Daly wrote:
> On Wed, Nov 02, 2022 at 12:29:49AM +0800, Drweb Mike wrote:
Hi there,
> > My front end is nginx using reverse proxy work with my backend, I was
> > trying to cache images files only, but it seems doesn't work at all, the
> > *$no_cache* always output default value "proxy", which should be "0" when I
> > visit image files
> If you want to use variables to decide whether nginx should handle a
> request by looking in the cache before asking upstream, you should only
> use variables that are available in the request, not ones that come
> from upstream.
>
> (Maybe you can use part of the request uri -- starts with /images/ or
> ends with .jpg or .png, for example? It depends on what requests your
> clients will be making.)
proxy_cache_bypass (http://nginx.org/r/proxy_cache_bypass) is "nginx
should not look in the cache for this response; go straight to upstream".
proxy_no_cache (http://nginx.org/r/proxy_no_cache) is "nginx should not
save this response from upstream to the cache".
Maybe you want to never use proxy_cache_bypass; and use proxy_no_cache
to make sure that only the things that should be written to the
cache, are written there? You could do proxy_no_cache based on
$upstream_http_content_type; and that any other requests will look in
the cache, see nothing there, and go to upstream anyway.
Cheers,
f
--
Francis Daly francis@daoine.org
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org