我只想缓存来自特定位置的内容。但是当我尝试使用正则表达式时,它不是缓存。
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,它会缓存所有内容。
注意:可能的 URL 模式
1. /v1/mydata/studies/{study_id}/ #不要cahce 2. /v1/mydata/studies//series/{series_id}/ # 不缓存 3. /v1/mydata/studies//series/{series_id}/instances/{instance_id}/ #不要cahce 4. /v1/mydata/studies//series/{series_id}/instances/{instance_id}/rendered # 缓存这个