proxy_cache_path levels

yolabingo nginx-forum at forum.nginx.org
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; 
    /data/nginx/cache/d7b6e5978e3f042f52e875005925e51b

# 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;  
    /data/nginx/cache/b/51/d7b6e5978e3f042f52e875005925e51b

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

# 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;  
    /data/nginx/cache/1b/e5/25/d7b6e5978e3f042f52e875005925e51b


# levels=2 
proxy_cache_path  /data/nginx/cache levels=2;  
    /data/nginx/cache/1b/d7b6e5978e3f042f52e875005925e51b


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
subdirectory.
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
00-ff). 

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

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,2450,273132#msg-273132



More information about the nginx mailing list