Problems with cache by mime/type

Francis Daly francis at daoine.org
Fri Nov 30 13:12:07 UTC 2018


On Thu, Nov 29, 2018 at 09:51:13PM -0200, Jorge Pereira wrote:

Hi there,

> I am using the nginx/1.12.0 and I am trying to use the below config.
> but, the below "map" by "$upstream_http_content_type" is always
> matching with default value "1". but, if I remove "proxy_cache_bypass"
> then the map it works. therefore, I need the "proxy_cache_bypass "
> capability.

It looks like you want to bypass the cache (and therefore always serve
these requests from upstream), for certain requests.

Is that correct?

If so -- you must set the "$no_cache" variable based on something in
the request, not on something in the response like a $sent_http_ variable.

>   map $sent_http_content_type $no_cache {
>     default                   1;
> 
>     application/zip           0;  # *.zip files
>     application/octet-stream  0;  # /artifactory/api/pypi and any
> other binary files.
>     application/java-archive  0;  # *.jar
>     application/x-nupkg       0;  # /artifactory/api/nuget/.*/Download/.*
>   }

Perhaps try setting $no_cache based on $request_uri or $document_uri? That
might fit three of the four above.

(Alternatively: set $no_cache to 0 by default, and to 1 based on requests
that you are happy to potentially have served from the cache.)

>     proxy_cache               artifactory_cache;
>     proxy_cache_bypass        $no_cache;
>     proxy_no_cache            $no_cache;

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list