Prevent cache from storing files multiple times in the proxy_temp dir

Our nginx reverse proxy creates a temporary entry in the proxy_temp
directory if that file does not yet exists in the cache. So far so good
but
if the file does not exists and the file will be requested 10 times at
the
same time it creates 10 temporary files in the proxy_temp and fetches
the
data 10 times from the proxied server. The result is high write IO and
high
bandwidth for a single file.

I already tested “proxy_cache_lock on” and played with the directive
“proxy_cache_lock_timeout” which addresses the issue. The disadvantage
is
that 1 connection will get the data but 9 are delayed because of the
lock.
The optimal solution would be if all the 10 hypothetic connections will
be
served from the same temporary cache file out of the proxy_temp.

Is there a good/better approach to solve this scenario?

TIA

Posted at Nginx Forum: