Usually I will do the following setting:
select(STDOUT);
$| = 1;
print "Content-type: text/html\n\n"; # whenever your browser sees this, it will blank the screen
$| = 0;
$| = 1; is to make sure to send data to client web browser immediately. It is like a "live" connection.
$| = 0; is to make sure to send data to client web browser only when the buffer is filled.
Such configuration can make the user feel that the response of the web is fast but it is actually just slightly faster.
If you use $| = 1; throughout the HTML code spitting process, your web can be slower as it is wasting the buffer and burst capability of TCP connections. Unless you want to have live output capability such as the ping result from the server, avoid setting it to live output mode.
No comments:
Post a Comment