proxy_cache_path levels

yolabingo nginx-forum at
Wed Mar 22 22:54:51 UTC 2017

Results of queries for the same URL using different settings for
proxy_cache_path "levels" 

# levels not specified, so all cache files reside in a single directory
proxy_cache_path  /data/nginx/cache; 

# a lot of config examples use levels=1:2 - this provides 16 x 256 = 4096
directories in 2 levels
proxy_cache_path  /data/nginx/cache levels=1:2;  

# levels=1:1:1 also provides 16^3 = 4096 directories, but in 3 levels
proxy_cache_path  /data/nginx/cache levels=1:1:1;  

# levels=2:2:2 provides the maximum possible number of directories 256^3 =
~16 million 
proxy_cache_path  /data/nginx/cache levels=2:2:2;  

# levels=2 
proxy_cache_path  /data/nginx/cache levels=2;  

levels= instructs Nginx to create subdirectories within proxy_cache_path
You can specify up to 3 colon-separated digits to create up to 3 levels of
The colon-separated digits can be either "1" or "2" to define if that level
should contain 16 (0-f) or 256 (00-ff) subdirectories.
These directory names are a single- double-place hexidecimal value (0-f or

Cache files reside in directories that correspond to the last few hex values
of the file name.

Posted at Nginx Forum:,2450,273132#msg-273132

More information about the nginx mailing list