mardi 10 septembre 2019

how can I use AND operator in IF statement in nginx?

I'm trying to cache the request based on the response header. Right now my desire condition is if the response has both 2 headers client-device and client-location, then the response should be cached on nginx side

So I tried with this code

if ($http_client_device && $http_clocation) {
    set $cache_key "$request_uri$http_client_device$http_client_location";
}
proxy_cache_key $cache_key;

but nginx doesn't allow that nginx: [emerg] unexpected "&&" in condition in...

anyway to work around for this one? thanks in advance

Aucun commentaire:

Enregistrer un commentaire