How can I know the name of the cache file created by NGINX?

Suppose I make a request, https://example.com/path1/2?v=1, and have enabled the proxy caching. How do I know the name of the cache file created by NGINX? The problem is, I want to delete the cache for a single URL and do not want to clear the complete NGINX cache. How can I do this?

enter image description here

These are the files inside my NGINX cache directory.


Solution 1:

According to the documentation cache file name is a result of applying MD5 function to a result of proxy_cache_key evaluation.

What you can try:

  • check what's in proxy_cache_key in your config
  • evaluate all the variables like $host and $request_uri manually for your target request
  • md5-it (careful about the line ending character)
  • see if you can find the resulting file and try to move it to other place

MD5 without \n at the end:

printf "example.com/path1/2?v=1" | md5sum