我有这个配置
location ~* \.php$ {
try_files $uri /index.php =404;
fastcgi_pass phpstream;
fastcgi_index index.php;
fastcgi_cache GCache;
fastcgi_cache_valid 200 120m;
fastcgi_cache_min_uses 1;
}
我想让持续时间对某些位置而不是120m
所有位置都动态,所以我尝试了
location ~* \.php$ {
try_files $uri /index.php =404;
fastcgi_pass phpstream;
fastcgi_index index.php;
set $duration = 120m;
if ($request_uri ~ ^/([0-9]+)/$) {
set $duration 30s;
}
fastcgi_cache GCache;
fastcgi_cache_valid 200 $duration;
fastcgi_cache_min_uses 1;
}
但我得到了错误
2022/08/21 22:11:12 [emerg] 1#1: invalid time value "$duration" in /etc/nginx/conf.d/data.conf
nginx: [emerg] invalid time value "$duration" in /etc/nginx/conf.d/data.conf
我想让动态内容每 30 秒更新一次,这样如果动态内容更新,它就会每 30 秒更新一次,但其余部分则不同