强烈建议开启,可以避免重新打开同一文件带来的系统开销,节省响应时间。如果并发比较小的网站,没必要开启了。
Syntax: | open_file_cache off; open_file_cache max=N [inactive=time]; |
---|---|
Default: | open_file_cache off; |
Context: | http , server , location |
Configures a cache that can store:
- open file descriptors, their sizes and modification times;
- information on existence of directories;
- file lookup errors, such as “file not found”, “no read permission”, and so on.Caching of errors should be enabled separately by the open_file_cache_errors directive.
主要存储:打开文件描述符、它们的大小和修改时间; 关于目录存在的信息; 文件查找错误,如“找不到文件”、“没有读取权限”等
The directive has the following parameters参数介绍:
max
sets the maximum number of elements in the cache; on cache overflow the least recently used (LRU) elements are removed;
inactive
defines a time after which an element is removed from the cache if it has not been accessed during this time; by default, it is 60 seconds;
off
disables the cache.
最大值
设置高速缓存中元素的最大数量;在高速缓存溢出时,移除最近最少使用的(LRU)元素;
不活跃的
定义了一个时间,在该时间之后,如果某个元素在此期间未被访问,则将其从高速缓存中删除;默认情况下为60秒;
关 禁用缓存。
Example:
open_file_cache max=1000 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache_errors on;
Syntax: | open_file_cache_errors on | off; |
---|---|
Default: | open_file_cache_errors off; |
Context: | http , server , location |
Enables or disables caching of file lookup errors by open_file_cache.
启用或禁用open_file_cache对文件查找错误的缓存。如果开启可能无法立刻发现错误,但是稍后还是会发现的。
Syntax: | open_file_cache_min_uses number; |
---|---|
Default: | open_file_cache_min_uses 1; |
Context: | http , server , location |
Sets the minimum number
of file accesses during the period configured by the inactive
parameter of the open_file_cache directive, required for a file descriptor to remain open in the cache.
设置在open_file_cache指令的非活动参数配置的时间段内的最小文件访问次数,这是文件描述符在缓存中保持打开状态所必需的。至少这个次数后才加入到缓存中。
Syntax: | open_file_cache_valid time; |
---|---|
Default: | open_file_cache_valid 60s; |
Context: | http , server , location |
Sets a time after which open_file_cache elements should be validated.设置验证open_file_cache元素的时间。