bounty将在7天后过期。回答此问题可获得+50声望奖励。Gill Bates希望奖励现有回答。
我尝试根据响应头缓存请求。现在我希望的条件是,如果响应同时有2个头client-device和client-location,那么响应应该缓存在nginx端
所以我试着用这个代码
if ($http_client_device && $http_clocation) {
set $cache_key "$request_uri$http_client_device$http_client_location";
}
proxy_cache_key $cache_key;
但是nginx不允许使用nginx:[emerg]在条件中出现意外的“&&”...
无论如何要为这一个工作?提前感谢
2条答案
按热度按时间li9yvcax1#
经过一整天的搜索,我找到了一个解决办法,参考这个主题http://rosslawley.co.uk/archive/old/2010/01/04/nginx-how-to-multiple-if-statements/
一般来说,我的代码看起来像这样:
但是我仍然想知道在nginx中有没有更干净的方法来执行AND操作符
e0bqpujr2#
我使用以下语法
例如:
可达到
参考:Nginx
if
,and
对于您的情况