how can i set diffrent proxy cache time by diffrent uri

vps4 nginx-forum at forum.nginx.org
Mon Feb 15 10:11:40 UTC 2016


i tried to use like this

server {

    set $cache_time 1d;

    if ($request_uri = "/") {
        set $cache_time 3d;
    }

    if ($request_uri ~ "^/other") {
        set $cache_time 30d;
    }

    location / {
        try_files $uri @fetch;
    }

    location @fetch {
         proxy_cache_valid  200 301 302 $cache_time;
    }
}

then i got error "invalid time value "$cache_time" in /etc/nginx/xxx.conf

how can i fix this?

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,264539,264539#msg-264539



More information about the nginx mailing list