我只想缓存特定位置的内容。但是当我尝试使用正则表达式时,它不是缓存。
proxy_cache_path /AINginxService/nginx-1.16.1/cache/ levels=1:2 keys_zone=one:10m max_size=8g inactive=5d use_temp_path=off;
proxy_cache one;
location ~* /v1/mydata/studies/[0-9.]+/series/[0-9.]+/instances/[0-9.]+/rendered {
#rewrite http://([^/]+)/rendered break;
proxy_cache_valid 200 120h;
proxy_pass http://127.0.0.1:9000/v1/mydata;
proxy_set_header Host $host;
proxy_pass_request_headers on;
proxy_http_version 1.1;
proxy_set_header Origin "";
proxy_connect_timeout 1d;
proxy_send_timeout 1d;
proxy_read_timeout 1d;
send_timeout 1d;
}
# Rest api entry point
location /v1/mydata {
#proxy_cache_valid 200 120h;
proxy_pass http://127.0.0.1:9000/v1/mydata;
proxy_set_header Host $host;
proxy_pass_request_headers on;
proxy_http_version 1.1;
proxy_set_header Origin "";
proxy_connect_timeout 1d;
proxy_send_timeout 1d;
proxy_read_timeout 1d;
send_timeout 1d;
}
}
PS :如果我取消注释/ v1 / mydata中的proxy_cache_valid,它将缓存所有内容。
注意:可能的网址格式
1. /v1/mydata/studies/{study_id}/ # Not to cahce 2. /v1/mydata/studies//series/{series_id}/ # Not to cache 3. /v1/mydata/studies//series/{series_id}/instances/{instance_id}/ # Not to cahce 4. /v1/mydata/studies//series/{series_id}/instances/{instance_id}/rendered # Cache this