Nginx的proxy_cache_path

proxy_cache_path

Syntax: proxy_cache_path path [ levels = levels ] keys_zone = name : size [ inactive = time ] [ max_size = size ] [ loader_files = number ] [ loader_sleep = time ] [ loader_threshold = time ]
Default:
Context: http
Reference: proxy_cache_path
 
This directive sets the cache path and other cache parameters. Cached data is stored in files. An MD5 hash of the proxied URL is used as the key for the cache entry, and is also used as the filename in the cache path for the response contents and metadata. The levels parameter sets the number of subdirectory levels in cache. For example:
 
proxy_cache_path  /data/nginx/cache/one  levels=1:2   keys_zone=one:10m;
In this cache, file names will be like the following:
 
/data/nginx/cache/c/29/b7f54b2df7773722d382f4809d65029c
You may use any combination of 1 and 2 in the level formats: X, X:X, or X:X:X e.g.: "2", "2:2", "1:1:2". There can be at most 3 levels.
 
All active keys and metadata is stored in shared memory. Zone name and the size of the zone is defined via the keys_zone parameter.
 
Note that each defined zone must have a unique path. For example:
 
proxy_cache_path  /data/nginx/cache/one    levels=1      keys_zone=one:10m;
proxy_cache_path  /data/nginx/cache/two    levels=2:2    keys_zone=two:100m;
proxy_cache_path  /data/nginx/cache/three  levels=1:1:2  keys_zone=three:1000m;
If cached data is not requested for time defined by the inactive parameter, than that data is removed from the cache. The inactive parameter defaults to 10 minutes (10m).
 
A special process, called "cache manager", is created to control the on-disk cache. It is responsible for removing inactive items and enforcing the size of the cache, as defined by the parameter max_size. When the total size of the cache exceeds the maximum size set by max_size, the least recently used data in the cache is deleted to make room for a new cache entry (a LRU replacement policy).
 
Zone size should be set proportional to number of pages to cache. The size of the metadata for one page (file) depends on the OS; currently it is 64 bytes for FreeBSD/i386, and 128 bytes for FreeBSD/amd64.
 
The directories specified by proxy_cache_path and proxy_temp_path should be located on the same filesystem.

你可能感兴趣的:(Nginx的proxy_cache_path)