We are observing that multiple cache object is getting created for same file in Nginx Cache which is resulting into non optimal use of cache storage.
We are using proxy_cache_key as $uri.
proxy_cache_key $uri;
For example with file having URI /content/entry/jiomags/content/719/51/51_t_0.jpg
2 cache object has been created in cache folder. Both the files are having same KEY
-rw------- 1 nginx nginx 21023 Jun 27 16:11 ./2/95/9d78505da184e6ccd981fefe6b333952
-rw------- 1 nginx nginx 21023 Jun 27 18:16 ./f/ad/c8e1c56031a14dd4a27e538956253adf
vi ./2/95/9d78505da184e6ccd981fefe6b333952
KEY: /content/entry/jiomags/content/719/51/51_t_0.jpg
HTTP/1.1 200 OK^M
Server: nginx^M
Date: Sat, 27 Jun 2020 10:41:01 GMT^M
Content-Type: image/jpeg^M
Content-Length: 20369^M
Connection: close^M
Last-Modified: Fri, 10 Jan 2020 15:20:59 GMT^M
Vary: Accept-Encoding^M
ETag: "5e18965b-4f91"^M
Expires: Sun, 26 Jul 2020 20:17:15 GMT^M
Cache-Control: max-age=2592000^M
Access-Control-Allow-Origin: *^M
Access-Control-Expose-Headers: Content-Length,Content-Range^M
Access-Control-Allow-Headers: Range^M
Accept-Ranges: bytes^
vi ./f/ad/c8e1c56031a14dd4a27e538956253adf
KEY: /content/entry/jiomags/content/719/51/51_t_0.jpg
HTTP/1.1 200 OK^M
Server: nginx^M
Date: Sat, 27 Jun 2020 12:46:06 GMT^M
Content-Type: image/jpeg^M
Content-Length: 20369^M
Connection: close^M
Last-Modified: Fri, 10 Jan 2020 15:20:59 GMT^M
Vary: Accept-Encoding^M
ETag: "5e18965b-4f91"^M
Expires: Mon, 27 Jul 2020 12:46:06 GMT^M
Cache-Control: max-age=2592000^M
Access-Control-Allow-Origin: *^M
Access-Control-Expose-Headers: Content-Length,Content-Range^M
Access-Control-Allow-Headers: Range^M
Accept-Ranges: bytes^M
What could be the reason for duplicate file getting cached having same URI and KEY.
Please help