Zend Framework - Same browser open multiple tabs but wait for first request to finished

别等时光非礼了梦想. 提交于 2019-12-25 02:29:49

问题


I have issue with same browser client try to open multiple tabs with it. but my server is wait for first request to finished.

for example

  1. Open first browser tab that take more time like 30sec.

  2. Now, next tab open with the help of CTR + Mouse click open new tab in bowser that is just static page 1 sec wait; but stil i have to wait for first request to finished.

Note : I have website in not in live but i am using following technology PHP 5.4, Mysql, Zend Framework 2.1, Xampp 1.8

Please guide in above issue if an confution you can comment on it. I am happy to do chat also.


回答1:


I guess you have session_start() on every page.

Default PHP session is based on files. Hence whenever the session_start() is called the file lock will occur on the server. Until complete the process the file lock won't be released.

To resolve this problem use session_write_close() on your page. Use this session write close efficiently. Once you written everything into the session then close it.

session_write_close() will release the lock. After session_write_close() you can read the data from session but you can't write it. If you want to write it then you need to restart the session again using session_start().

Session data is usually stored after your script terminated without the need to call session_write_close(), but as session data is locked to prevent concurrent writes only one script may operate on a session at any time. When using framesets together with sessions you will experience the frames loading one by one due to this locking. You can reduce the time needed to load all the frames by ending the session as soon as all changes to session variables are done.

Ref:

http://www.php.net//manual/en/function.session-write-close.php http://www.php.net/manual/en/function.session-start.php



来源:https://stackoverflow.com/questions/24324994/zend-framework-same-browser-open-multiple-tabs-but-wait-for-first-request-to-f

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!