1.关闭缓存
proxy_buffering off; # 关闭代理缓冲
fastcgi_keep_conn on; # 保持长连接
output_buffering = 0 ; 完全关闭PHP缓冲
2.时间延长
# 设置连接超时时间(如300秒) keepalive_timeout 300;
# 单个连接最大请求数 keepalive_requests 100;
fastcgi_read_timeout
php-fpm.conf---request_terminate_timeout
3.代码
set_time_limit(0);
ob_implicit_flush(1); // 自动刷新输出缓冲
ob_end_flush(); // 关闭缓冲
header('Content-Type: text/event-stream');
header('Cache-Control: no-cache');