September 15, 2016 04:42AM
Hello dream team,

I have problem when i use "proxy_cache" with a variable ! Using "proxy_cache_purge" (call to proxy_cache) directive with a variable seems to change that variable's value.
Tested on the last version nginx/1.11.4 (on Sles11 SP3)

I would change my name cache dynamically

The following conf is OK : (the file is purged)

########################################################################
server {
.....
location ~ /purge(/.*) {
allow 127.0.0.1;
deny all;

set $cacheSelect carto;
#echo "Zone:$cacheSelect"; //Display carto
proxy_cache_purge $cacheSelect $host$1$is_args$args; //Return code 200 => File purged from the cache
}

...
}

########################################################################

But if i use "map" or "if" for change the cache variable, the problem appears :

For example this URL : test.com/purge/librairies/test.js => I make sure the file exists in the cache before

########################################################################

map $uri $select_cache {
default 'carto';
~*/tuiles/ 'tuiles';
~*/librairies/ 'librairies';
}

server {
.....
location ~ /purge(/.*) {
allow 127.0.0.1;
deny all;

set $cacheSelect carto; //carto is the default value
if ($uri ~ /librairies/(.*)$ ) {
set $cacheSelect librairies;
}

echo "Zone:$cacheSelect"; //Display librairies
echo "Zone:$select_cache"; //Display librairies

#proxy_cache_purge $select_cache $host$1$is_args$args; ==> Return 404 (file not found in cache)
proxy_cache_purge $cacheSelect $host$1$is_args$args; ==> Return 404 (file not found in cache)
}
...
}
########################################################################
I feel that when I use "if" or "map" in my conf it does not work anymore

Thank you for your help
Subject Author Posted

Proxy_cache with variable

Jugurtha September 15, 2016 04:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 164
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready