序
keepalive_timeout
keepalive_requests
ngx_http_core_module
nginx/src/http/ngx_http_core_module.c
ngx_http_header_filter
nginx/src/http/ngx_http_header_filter_module.c
小结
nginx提供了keepalive_timeout(一个keep-alive连接在服务端保持open的时间
)及keepalive_requests(一个keep-alive连接最大处理的请求数
)参数,其中ngx_http_core_module的ngx_http_update_location_config(ngx_http_request_t *r)方法在keepalive为true时,若connection的requests的requests大于等于配置的keepalive_requests,则设置keepalive为0;若ngx_current_msec减去connection的start_time等于keepalive_time则设置keepalive为0;而ngx_http_header_filter_module的ngx_http_header_filter方法,在keepalive为1时会添加Connection: keep-alive
,若开启keepalive_header,则添加Keep-Alive: timeout=%T"
;若keepalive为0时,则添加Connection: close
到response的header。
doc
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。