1

i have this configure

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; } 

i wanna make the duration dynamic for some locations instead of 120m for all so i tried

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; } 

but i get error

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 

i wanna make it 30s for dynamic content so it updates every 30s if the dynamic content updated but the rest is different

2
  • fastcgi_cache_valid does not accept variables as its value. Commented Aug 25, 2022 at 20:08
  • @DanilaVershinin can not be done around it maybe all of it in condition? Commented Aug 25, 2022 at 21:27

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.