PHP 7.1.0 Release Candidate 4 Released


(PHP 5 >= 5.3.3, PHP 7)



boolean fastcgi_finish_request ( void )

この関数は、すべてのレスポンスデータをクライアントにフラッシュし、 リクエストを終わらせます。 これにより、クライアントへの接続を開いたままにすることなく、 時間のかかる処理を実行することができます。


成功した場合に TRUE を、失敗した場合に FALSE を返します。

add a note add a note

User Contributed Notes 1 note

2 months ago
There are some pitfalls  you should be aware of when using this function.

The script will still occupy a FPM process after fastcgi_finish_request(). So using it excessively for long running tasks may occupy all your FPM threads up to pm.max_children. This will lead to gateway errors on the webserver.

Another important thing is session handling. Sessions are locked as long as they're active (see the documentation for session_write_close()). This means subsequent requests will block until the session is closed.

You should therefore call session_write_close() as soon as possible (even before fastcgi_finish_request()) to allow subsequent requests and a good user experience.

This also applies for all other locking techniques as flock or database locks for example. As long as a lock is active subsequent requests might bock.
To Top