Keep-alive and Safari
Igor Sysoev
igor at sysoev.ru
Thu Nov 25 19:09:31 MSK 2010
On Thu, Nov 25, 2010 at 04:49:52PM +0100, Jan Andersson wrote:
> Hi,
> regading:
>
> >> I also founded NGIX disabled keep-alive for safari.
> >>
> >> I am not sure exact reason of this.
> >
> > http://nginx.org/pipermail/nginx/2010-October/023131.html
>
> I still beleive it would be great if there was an option to enable keep-alive for Safari.
> Not all sites need this work-a-round...
The attached patch introduces
safari_keepalive on|off;
directive. The default value is "off".
It will be included in next 0.9.0.
--
Igor Sysoev
http://sysoev.ru/en/
-------------- next part --------------
Index: src/http/ngx_http_core_module.c
===================================================================
--- src/http/ngx_http_core_module.c (revision 3111)
+++ src/http/ngx_http_core_module.c (working copy)
@@ -564,6 +564,13 @@
offsetof(ngx_http_core_loc_conf_t, msie_refresh),
NULL },
+ { ngx_string("safari_keepalive"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, safari_keepalive),
+ NULL },
+
{ ngx_string("log_not_found"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
ngx_conf_set_flag_slot,
@@ -790,24 +797,12 @@
break;
}
- if (r->keepalive) {
-
- if (r->headers_in.msie6) {
- if (r->method == NGX_HTTP_POST) {
- /*
- * MSIE may wait for some time if an response for
- * a POST request was sent over a keepalive connection
- */
- r->keepalive = 0;
- }
-
- } else if (r->headers_in.safari) {
- /*
- * Safari may send a POST request to a closed keepalive
- * connection and stalls for some time
- */
- r->keepalive = 0;
- }
+ if (r->keepalive && r->headers_in.msie6 && r->method == NGX_HTTP_POST) {
+ /*
+ * MSIE may wait for some time if an response for
+ * a POST request was sent over a keepalive connection
+ */
+ r->keepalive = 0;
}
if (r->headers_in.content_length_n > 0) {
@@ -1432,6 +1427,14 @@
} else if (r->connection->requests >= clcf->keepalive_requests) {
r->keepalive = 0;
+
+ } else if (r->headers_in.safari && !clcf->safari_keepalive) {
+ /*
+ * Safari may send a POST request to a closed keepalive
+ * connection and stalls for some time, see
+ * https://bugs.webkit.org/show_bug.cgi?id=5760
+ */
+ r->keepalive = 0;
}
}
@@ -3092,6 +3095,7 @@
clcf->port_in_redirect = NGX_CONF_UNSET;
clcf->msie_padding = NGX_CONF_UNSET;
clcf->msie_refresh = NGX_CONF_UNSET;
+ clcf->safari_keepalive = NGX_CONF_UNSET;
clcf->log_not_found = NGX_CONF_UNSET;
clcf->log_subrequest = NGX_CONF_UNSET;
clcf->recursive_error_pages = NGX_CONF_UNSET;
@@ -3337,6 +3341,7 @@
ngx_conf_merge_value(conf->port_in_redirect, prev->port_in_redirect, 1);
ngx_conf_merge_value(conf->msie_padding, prev->msie_padding, 1);
ngx_conf_merge_value(conf->msie_refresh, prev->msie_refresh, 0);
+ ngx_conf_merge_value(conf->safari_keepalive, prev->safari_keepalive, 0);
ngx_conf_merge_value(conf->log_not_found, prev->log_not_found, 1);
ngx_conf_merge_value(conf->log_subrequest, prev->log_subrequest, 0);
ngx_conf_merge_value(conf->recursive_error_pages,
Index: src/http/ngx_http_core_module.h
===================================================================
--- src/http/ngx_http_core_module.h (revision 3111)
+++ src/http/ngx_http_core_module.h (working copy)
@@ -367,6 +367,7 @@
ngx_flag_t port_in_redirect; /* port_in_redirect */
ngx_flag_t msie_padding; /* msie_padding */
ngx_flag_t msie_refresh; /* msie_refresh */
+ ngx_flag_t safari_keepalive; /* safari_keepalive */
ngx_flag_t log_not_found; /* log_not_found */
ngx_flag_t log_subrequest; /* log_subrequest */
ngx_flag_t recursive_error_pages; /* recursive_error_pages */
More information about the nginx
mailing list