mod/chat - Normal method now support HTTP Keep-Alive

By using output buffering, we now support HTTP Keep-Alive, which means
that each client gets tightly bound to a single apache child - this means
that we get

 + lower resource usage on the webserver
 + _much_ lower resource usage on webserver and dbserver if pconnects are used
 + a good case for further caching (memcache/mmcache)

Using ab via localhost or fast LAN using keepalives is actually slower from the
client perspective -- still lighter on the server. Via slower links (DSL/modem)
the responses are faster.
This commit is contained in:
martinlanghoff 2006-04-17 21:04:19 +00:00
parent 4d5525c650
commit dfd1d9e272

View file

@ -61,7 +61,8 @@
$chat_newrow = ($chat_lastrow + $num) % 2; $chat_newrow = ($chat_lastrow + $num) % 2;
$refreshurl = "jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow"; // no & in url, does not work in header! // no & in url, does not work in header!
$refreshurl = "{$CFG->wwwroot}/mod/chat/gui_header_js/jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow";
header('Expires: Sun, 28 Dec 1997 09:32:45 GMT'); header('Expires: Sun, 28 Dec 1997 09:32:45 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
@ -76,6 +77,10 @@
$stylesheetshtml .= '<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"'.$stylesheet.'\\" />'; $stylesheetshtml .= '<link rel=\\"stylesheet\\" type=\\"text/css\\" href=\\"'.$stylesheet.'\\" />';
} }
// use ob to be able to send Content-Length headers
// needed for Keep-Alive to work
ob_start();
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html> <html>
@ -151,3 +156,12 @@
<a href="<?php echo $refreshurl ?>" name="refreshLink">Refresh link</a> <a href="<?php echo $refreshurl ?>" name="refreshLink">Refresh link</a>
</body> </body>
</html> </html>
<?php
// support HTTP Keep-Alive
header("Content-Length: " . ob_get_length() );
ob_end_flush();
exit;
?>