Clean up the connection buffer if there is no data in it.

This patch automatically reduces the memory footprint of a long-running connection, while still allowing high-throughput clients and servers to fill the underlining socket.

There is still some space for further optimizations: I believe it is possible to remove the 'cache buffer' totally.