11

nginx高并发优化之静态文件缓存配置

 1 year ago
source link: https://blog.51cto.com/u_13236892/5845205
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

nginx高并发优化之静态文件缓存配置

精选 原创

哭泣的馒头 2022-11-11 16:55:16 博主文章分类:nginx指南 ©著作权

文章标签 缓存 服务器 文件描述符 文章分类 Linux 系统/运维 yyds干货盘点 阅读数343

http {
open_file_cache max=65535 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 4;
open_file_cache_errors on;
}
NGINX虽然已经对静态内容做过优化。但在高流量网站的情况下,仍然可以使用open_file_cache进一步提高性能。
NGINX缓存将最近使用的文件描述符和相关元数据(如修改时间,大小等)存储在缓存中。缓存不会存储所请求文件的内容

1、open_file_cache
open_file_cache max=65535 inactive=20s;
打开缓存的同时也指定了缓存最大数目,以及缓存的时间 max指定缓存数量,建议和打开文件数一致
inactive 是指经过多长时间文件没被请求后删除缓存。

2、open_file_cache_valid
检验缓存中元素有效性的频率;默认为60s

3、open_file_cache_min_uses
open_file_cache指令中的inactive 参数时间内文件的最少使用次数,如果超过这个数字,文件描述符一直是在缓存中打开的。
如上例,如果有一个文件在inactive 时间内不超过四次被使用,它将被移除。

4、open_file_cache_errors
指定了当搜索一个文件时是否缓存错误信息,也包括再次给配置中添加文件。我们也包括了服务器模块,这些是在不同文件中定义的。
如果你的服务器模块不在这些位置,你就得修改这一行来指定正确的位置。
  • 收藏
  • 评论
  • 分享
  • 举报

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK