proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$request_uri"; < — see here, with the same success playing with these headers does the same thing, so it is necessary to cache not the entire request URI, and only the script name ($request_filename).