New AWS instance with Amazon Linux 2023 + LAMP stack - this very basic example php script fails to stream the response. It dumps the entire content after a few seconds.
<?php
ob_implicit_flush(1);
ob_end_flush();
for($a=1; $a<20; $a++)
{
echo "Hello! ";
ob_flush();
flush();
usleep(100000);
}
I've got it working but do not understand why, perhaps someone who knows more than me can explain.
Lucky for me I had my old AWS instance with Amazon Linux 2 that worked fine. Same Apache/PHP versions. I noticed the response headers differed between the two servers.
My old server...
HTTP/1.1 200 OK
Upgrade: h2,h2c
Connection: Upgrade
New server...
HTTP/1.1 200 OK
So I diffed the httpd conf files from the two servers and landed on this being missing from the new AWS instance
httpd.conf
# Enable HTTP/2 by default
#
# https://httpd.apache.org/docs/2.4/mod/core.html#protocols
<IfModule mod_http2.c>
Protocols h2 h2c http/1.1
</IfModule>
I copied that over to my new servers httpd.conf restarted and all was good in the world. But I wonder why it was dropped from the config?