Home > Article > Backend Development > PHP Session Optimization Source Code_PHP Tutorial
The server SESSION of PHP does not end when the same client requests it, and the next request cannot be made!
For example, the following code:
client:
server:
session_start();
sleep(2);
echo '{json:"repsonse ' . $_GET["call"] . '"}';
?>
The above client takes more than 10 seconds to load.
After using SESSION, you can use session_write_close(); to close it, and the next request can be executed immediately!
Example:
session_start();
session_write_close();
sleep(2);
echo '{json:"repsonse ' . $_GET["call"] . '"}';
?>
The client loading time of the above code is reduced from 10s to 2s!