PHP – 在脚本结束前发送 HTTP 头部的简单方法
通常情况下,PHP 脚本会在所有处理完成之后才发送 HTTP 响应。如果你想在发送 302 重定向等头部信息后继续执行耗时操作(如 sleep),直接使用 header() 会导致客户端等待。本文介绍了一种无需复杂配置的简单方法,让 PHP 在发送完头部后继续后台处理,从而提升用户体验。
通常情况下,PHP 脚本会在所有处理完成之后才发送 HTTP 响应。如果你想在发送 302 重定向等头部信息后继续执行耗时操作(如 sleep),直接使用 header() 会导致客户端等待。本文介绍了一种无需复杂配置的简单方法,让 PHP 在发送完头部后继续后台处理,从而提升用户体验。
The article compares three approaches to serving files over HTTP in Linux: synchronous blocking I/O, epoll-based asynchronous I/O, and io_uring. It benchmarks each method using a simple file server, showing that io_uring offers the highest throughput and lowest latency, especially under high concurrency.