Ich habe eine Bitte: http://www.example.com/app?test=1
. 希望當(dāng)有 test=1
這個(gè)請求參數(shù)的時(shí)候緩存這這個(gè)url
. 請問 nginx
Kann das gemacht werden? .
Ich habe es in die Konfigurationsdatei geschrieben
service {
location /app {
if ( $arg_test ) {
//nginx 的 cache 的配置
}
}
}
Aber beim Starten wurde ein Fehler gemeldet. Sag es mir cache
不能配置在 if
im Block. . .
ringa_lee
首先,你當(dāng)然不能將全部
的配置放在if中
不過你可以這樣
location /app {
proxy_set_header Host $host;
proxy_cache_path /data/cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
if ( $arg_test ){
proxy_pass http://backend:backport;
}
}
這個(gè)回答可能也不符合你的要求, 但真的需要對cache的配置進(jìn)行條件化嗎?
帖個(gè)更細(xì)節(jié)點(diǎn)的配置文件也許能更了解你的需求...
歡迎關(guān)注本人segmentfault博客.