当使用 php-mod 和 fastcgi 时,代码完美地执行,每一秒我都会得到一个输出,但切换到 php-fpm 代码在输出之前滞后几秒钟,具体取决于输出大小在 php ini ob_implicit_flush ob_start ob_end_flush header Content-Encoding = noneimplicit_flush 1 ob_end_clean 中尝试了以下和设置输出缓冲区 0 的组合<?php header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); while( true ){ $time = date('r'); echo "retry:1000\r\n"; echo "data: ".$time; echo "\r\n\r\n"; ob_flush(); flush(); sleep(1); } ?>这是用于生产服务器,而 php-mod 不是一个选项,我也让它在 Fastcgi 中使用 FcgidOutputBufferSize 0 是否有办法使代码在 php-fpm 上工作,以便像在 php-mod 中一样立即发送输出和fastcgi ?PS 运行:Ubuntu 18.04、Apache 2.4.29、PHP 7.2
1 回答
- 1 回答
- 0 关注
- 144 浏览
添加回答
举报
0/150
提交
取消