The HTTP protocol includes a special Transfer-Encoding header, which allows you to indicate that the page can be loaded into chunks ( Transfer-Encoding: chunked ), although there is no guarantee that the browser will do this (but most browsers).
The Transfer-Encoding: chunked header tells the browser that the web server does not know Content-Length in advance.
Although you usually want to use Ajax to load content after this page is fully loaded, you can use this technique to display, for example, terminal output in real time, without the need for JavaScript.
See this question on how to implement chunked answers in PHP.
source share