Home  >  Article  >  Backend Development  >  PHP Session Optimization Source Code_PHP Tutorial

PHP Session Optimization Source Code_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:21:46787browse

PHP Session optimization source code

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!

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/853762.htmlTechArticlePHP Session optimization source code PHP SESSION The server SESSION does not end when the same client requests, and the next request cannot be made! For example, the following code: client: html head meta http-equiv=Content-Ty...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn