Welcome! Log In Create A New Profile

Advanced

Re: Problems with cache by mime/type

Jorge Pereira
November 30, 2018 08:34AM
Hi Francis,

I sent the wrong snip. the correct is using
$upstream_http_content_type as can be seen below. basically, always
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.

http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

map $upstream_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/.*
}

proxy_cache_path $CACHE_FOLDER
levels=1:2
keys_zone=artifactory_cache:$CACHE_KEYS_SIZE
max_size=$CACHE_SIZE
inactive=$CACHE_DURATION
use_temp_path=off;

server {
listen 80;
server_name mywww.lan;

set $upstream https://172.16.0.1/artifactory;

proxy_read_timeout 10;
proxy_pass_header Server;
proxy_cookie_path ~*^/.* /;
proxy_next_upstream http_503 non_idempotent;
proxy_set_header Host $http_host;

proxy_cache artifactory_cache;
proxy_cache_bypass $no_cache;
proxy_no_cache $no_cache;

add_header X-Proxy-Cache $upstream_cache_status;

proxy_cache_key $scheme$proxy_host$request_uri$auth_cache_key;
proxy_cache_valid 200 24h;
proxy_ignore_headers "Set-Cookie" "Cache-control";

location ~/mypath(?<relative_uri>.*)$ {
proxy_pass $upstream${relative_uri}${is_args}${args};
}
}
}


--
Jorge Pereira
On Fri, Nov 30, 2018 at 11:12 AM Francis Daly <francis@daoine.org> wrote:
>
> 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@daoine.org
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Problems with cache by mime/type

Jorge Pereira November 29, 2018 06:52PM

Re: Problems with cache by mime/type

Francis Daly November 30, 2018 08:14AM

Re: Problems with cache by mime/type

Jorge Pereira November 30, 2018 08:34AM

Re: Problems with cache by mime/type

Francis Daly November 30, 2018 09:06AM

Re: Problems with cache by mime/type

Jorge Pereira November 30, 2018 09:16AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 68
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready