proxy

nginx proxy_cache для отдельных запросов

http {
 
proxy_cache_path  /var/cache/nginx/cacheone levels=1:2 keys_zone=cacheone:20m max_size=1024m;
 
...
}
 
server {
 
    ...
 
    set $mykey "";
 
    location ... {
         if ($query_string ~ "(foo.*)")
         {
             set $mykey $1;
             error_page 404  =  @cacheone;
             return 404;
         }
 
        ...
    }
 
    location @cacheone {
        proxy_cache cacheone;
        proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$mykey";
        proxy_cache_valid 200 301 302 304 7m;