jQuery simple load taking too much time for first call

无人久伴 提交于 2019-12-10 13:59:35

问题


My Simple jQuery's load statement taking too much time (50+ seconds). There is no server side issue and server's page logic is simple. I also have tried $.ajax, $.get and even tried using Manual AJAX call (XMLHttpRequest).

Following is the example with jQuery load.

$(function() {
    $('#frmPrd').live('submit', function(event) {
        event.preventDefault();
        mUrl = "page1.php";
        $.ajax({
            url: mUrl,
            type: 'POST',
            data: $("#frmPrd").serialize(),
            success: function() {
                //Logged Unix timestamp here which was 1448631101 (27 Nov 2015 13:31:41 GMT)
                $("#dvCart").load("page.php");
            },
            error: function() {
                alert('Error occurred.');
            }
        });
    });
});

And then in page.php I logged (very first statement of page) timestamp which returned 1448631153 (27 Nov 2015 13:32:33 GMT) i.e. 52 seconds difference from the timestamp I logged before calling the page. What can be the issue here? Where are these 50+ seconds wasted? Also note that this delay is for first call, for all coming calls the delay is normal. My whole website runs on https (TLS 1.2)


回答1:


It was initial handshake with https server which was taking time.



来源:https://stackoverflow.com/questions/33958840/jquery-simple-load-taking-too-much-time-for-first-call

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