From c5e817f02c1fdecd9aa3b6b941e2fa98dc227863 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Mon, 17 Apr 2006 21:05:17 +0000 Subject: [PATCH] mod/chat - Normal method - users pane only uses keepalive when refreshing fast To avoid wasting server resources, user's pane now only uses keepalive when the refresh is lower than apache's timeout. --- mod/chat/gui_header_js/users.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/mod/chat/gui_header_js/users.php b/mod/chat/gui_header_js/users.php index 159fcde791..7380712924 100644 --- a/mod/chat/gui_header_js/users.php +++ b/mod/chat/gui_header_js/users.php @@ -134,9 +134,24 @@ } echo ''; - // support HTTP Keep-Alive - header("Content-Length: " . ob_get_length() ); - ob_end_flush(); + // + // Support HTTP Keep-Alive by printing Content-Length + // + // If the user pane is refreshing often, using keepalives + // is lighter on the server and faster for most clients. + // + // Apache is normally configured to have a 15s timeout on + // keepalives, so let's observe that. Unfortunately, we cannot + // autodetect the keepalive timeout. + // + // Using keepalives when the refresh is longer than the timeout + // wastes server resources keeping an apache child around on a + // connection that will timeout. So we don't. + if ($CFG->chat_refresh_userlist < 15) { + header("Content-Length: " . ob_get_length() ); + ob_end_flush(); + } + exit; // no further output -- 2.39.5