There's different thresholds that avoid extra network latency increments:
If you can get it under 1500 bytes you can get it into a single ethernet frame and avoid electrical signal delay.
If you can get it under 9000 bytes then you can get it into a single jumbo frame and (sometimes, partially) avoid routing delay.
If you can get it under 64k then you can avoid IP fragmentation delays.
For each of these thresholds, time-to-first-byte could be optimized by flushing the output buffer at the threshold. However time-to-last-byte could be penalized if the full output would have come in under the next threshold anyway.
e.g. if you have a 63k page and you flush after 1500 bytes you'll end up sending two IP packets instead of 1 and the page won't be fully available until the second IP packet arrives whereas without the 1500 byte flush you would not be able to parse as early but you'd probably finish parsing earlier since there would be no need to ACK the first IP packet.
The generated code could be instrumented by the compiler to maintain heuristics for the size of each page. Any pages that usually surpass a threshold could have their output buffer flushed at the lowest threshold to optimize for TTFB.
(caveat: the time-to-last-byte penalty may not matter for HTTP/3 which uses UDP and thus no ACK)
There's different thresholds that avoid extra network latency increments:
For each of these thresholds, time-to-first-byte could be optimized by flushing the output buffer at the threshold. However time-to-last-byte could be penalized if the full output would have come in under the next threshold anyway.
e.g. if you have a 63k page and you flush after 1500 bytes you'll end up sending two IP packets instead of 1 and the page won't be fully available until the second IP packet arrives whereas without the 1500 byte flush you would not be able to parse as early but you'd probably finish parsing earlier since there would be no need to ACK the first IP packet.
The generated code could be instrumented by the compiler to maintain heuristics for the size of each page. Any pages that usually surpass a threshold could have their output buffer flushed at the lowest threshold to optimize for TTFB.
(caveat: the time-to-last-byte penalty may not matter for HTTP/3 which uses UDP and thus no ACK)