문제

I've just finished a CakePHP website which works like a charm in local. So, I put it online. The problem is that , although pages are generated pretty quickly (around 400ms), my browser shows the loading symbol for 5 long seconds.

My Firefox dev console shows that the browser is in "receiving" state for EXACTLY 5 seconds, every time. Actually, the page is displayed way before, but it seems that for some reason the connection stays open for precisely 5 seconds.

It's actually boring because, let alone the loading sign that appears even though the page is fully loaded and usable, AJAX calls will last 5 seconds too. So AJAX content can't be displayed before 5s, which is obviously unacceptable for users.

I've tested the problem on several computers, browsers, and internet connections. I've also tested a vanilla CakePHP on the same host, and encountered the same problem.

So do you have any idea of which host setting could cause that? I believe that this only can happen because the server is keeping the connection open, not because the client is. But i can't figure out the reason. I hope you will !

도움이 되었습니까?

해결책

I had the same problème. It's not the good solution, but you can force the php script to close http connection at the end of Ajax action :

function AjaxEdit(){
    // do some thing
    header( "Connection: Close" );
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top