jQuery简单加载第一次调用花费太多时间 [英] jQuery simple load taking too much time for first call

查看:165
本文介绍了jQuery简单加载第一次调用花费太多时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的简单jQuery的加载语句需要花费太多时间(50+秒)。没有服务器端问题,服务器的页面逻辑很简单。我也尝试过 $。ajax $。get ,甚至尝试使用手动AJAX调用(XMLHttpRequest)

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).

以下是jQuery加载的示例。

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.');
            }
        });
    });
});

然后在 page.php 中我记录了(非常第一个页面声明)时间戳返回1448631153(2015年11月27日13:32:33 GMT),即与我在调用页面之前记录的时间戳相差52秒。
这里有什么问题?这50多秒浪费在哪里?
另请注意,此延迟适用于首次通话,对于所有来电,延迟均正常。我的整个网站都运行在https(TLS 1.2)

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)

推荐答案

这是与https服务器的初始握手,需要时间。

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

这篇关于jQuery简单加载第一次调用花费太多时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆