]> git.mjollnir.org Git - moodle.git/commitdiff
mod/chat - Normal method now support HTTP Keep-Alive
authormartinlanghoff <martinlanghoff>
Mon, 17 Apr 2006 21:04:19 +0000 (21:04 +0000)
committermartinlanghoff <martinlanghoff>
Mon, 17 Apr 2006 21:04:19 +0000 (21:04 +0000)
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.

mod/chat/gui_header_js/jsupdate.php

index ba008fa93bd732b6838752ce6275b9b33f95bcd0..9085349ae55e660537371d79e45840e4d5b61bc4 100644 (file)
@@ -61,7 +61,8 @@
 
     $chat_newrow = ($chat_lastrow + $num) % 2;
 
-    $refreshurl = "jsupdate.php?chat_sid=$chat_sid&chat_lasttime=$chat_newlasttime&chat_lastrow=$chat_newrow"; // no &amp; in url, does not work in header!
+    // no &amp; 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('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
         $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">
 <html>
        <a href="<?php echo $refreshurl ?>" name="refreshLink">Refresh link</a>
     </body>
 </html>
+<?php
+
+// support HTTP Keep-Alive
+header("Content-Length: " . ob_get_length() );
+ob_end_flush(); 
+exit;
+
+
+?>