proxy_cache_path
Nginx的proxy_cache_path
精选 转载文章标签 proxy_cache_path 文章分类 Nginx 服务器
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图片缓存
搭建图片缓存机制的原理在于减少数据库的负担并加快静态资源的响应。
proxy cache nginx -
Nginx proxy_cache 使用示例
动态网站使用缓存是很有必要的。前段时间使用了 nginx proxy_stroe 来
nginx 服务器 运维 缓存 html