网站

时间:2018-01-31 21:26:31

标签: javascript google-chrome time server loading

最近我的网站遇到了问题:它开始加载真的很慢,我不知道为什么会这样。我用分析器查看了它,发现我的URL的结尾 - 这是一个作为查询字符串传递的ID - 大约需要13秒才能加载。我不知道造成这种情况的原因。我检查了脚本,部分禁用它们并且一起禁用但似乎没有任何帮助。例如: www.mysite.com/flat/5 /

我有时会看到,如果Chrome无法找到像图片这样的内容,则需要很长时间才能加载,但我没有丢失Chrome要加载的文件。

我附上截图,向您展示探查器显示的内容: enter image description here

编辑:添加了服务器端代码

<?php
include("header.php");

$flatType = (isset($_GET["flat_type"])) ? $_GET["flat_type"] : null;
$flatId = (isset($_GET["flat_id"])) ? $_GET["flat_id"] : null;

$sqlFlats = "SELECT * FROM lakasok a JOIN tanacsadok b ON (a.tanacsado_id = b.id) WHERE elado_kiado = '$flatType' AND a.id = '$flatId'";
$queryFlats = mysqli_query($con, $sqlFlats);

$flat = mysqli_fetch_assoc($queryFlats);

$district = ($flat["varos"] == "Budapest") ? $flat["kerulet"]." ".$lang["flat-single-district"] : "";
if ($flat["elado_statusz"] == 0 && $flatType == "elado") {
    $actual = '<b>'.$lang["flat-single-sell-available"].'</b> <span class="ft-thinest">/ '.$lang["flat-single-sell-unavailable"].'</span>';
} else if ($flat["kiado_statusz"] == 0 && $flatType == "kiado") {
    $actual = '<b>'.$lang["flat-single-rent-available"].'</b> <span class="ft-thinest">/ '.$lang["flat-single-rent-unavailable"].'</span>';
} else if ($flat["elado_statusz"] == 1 && $flatType == "elado") {
    $actual = '<span class="ft-thinest">'.$lang["flat-single-sell-available"].' /</span> <b>'.$lang["flat-single-sell-unavailable"].'</b>';
} else {
    $actual = '<span class="ft-thinest">'.$lang["flat-single-rent-available"].' /</span> <b>'.$lang["flat-single-rent-unavailable"].'</b>';
}
$price = ($flat["elado_kiado"] == "kiado") ? formatPrice($flat["ar_berles"])."Ft / ".$lang["general-month"] : formatPrice($flat["ar_vetel"]);
$lift = ($flat["lift"]) ? $lang["general-there-is"] : $lang["general-there-isnt"];
$description = ($language == "hu") ? $flat["leiras"] : $flat["leiras_en"];
$location = ($language == "hu") ? $flat["kornyek"] : $flat["kornyek_en"];

// echo "<br><br><br><br><br>";
// echo $sqlFlats;
// echo "<pre>";
// print_r($flat);
// echo "</pre>";

//Check the images
$imagesTmp = scandir("img/flats");

foreach ($imagesTmp as $key => $value) {
    $img = array();

    if (strlen($value) > 3 && strpos($value, formatLink($flat["cim"]."_".$flatId."_galery")) !== false && strpos($value, "_respo") !== false) {
        $img["respo"] = $value;
        $img["high_res"] = str_replace("_respo", "_high_res", $value);

        $galeryImages[] = $img;
    }
    $_flatImage = "";

    foreach ($imagesTmp as $key => $value) {
        //echo $value." == ".formatLink($flat["cim"]."_".$flatId)."_high_res<br>";
        if (strlen($value) > 3 && strpos($value, formatLink($flat["cim"]."_".$flatId)."_high_res") !== false && strpos($value, "_galery") == false) {
            $_flatImage = $value;
        }
    }

    if (is_file("img/flats/".$_flatImage)) {
        $flatImage = "img/flats/".$_flatImage."?".time();
    } else {
        $flatImage = 'img/nincs_kep.jpg';
    }
}
//Check the picture profile picture of the assistant
$imagesTmp = scandir("img/assistants");

foreach ($imagesTmp as $key => $value) {
    if (strlen($value) > 3 && strpos($value, formatLink($flat["nev"]."-".$flat["id"])) !== false) {
        $assistantImage = "assistants/".$value;
        break;
    } else {
        $assistantImage = "nincs_kep.jpg";
    }
}

// print_r($galeryImages);

?>
    <script src="js/elementInViewport.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            var flatDesc = $("#flat-desc");
            var flatInfoList = $("#flat-info-list");
            var flatInfoEstateAgent = $("#flat-info-estate-agent");
            var flatLocation = $("#flat-location");
            var estateAgent = $("#estate-agent");

            $('#imageGallery').lightSlider({
                gallery:true,
                loop:true,
                pauseOnHover: true,
                easing: 'cubic-bezier(0.25, 0, 0.25, 1)',
                speed: 600,
                auto: true,
                pause: 5000,
                item: 1,
                thumbItem:5,
                slideMargin:0,
                enableDrag: false,
                currentPagerPosition:'middle'
                // onSliderLoad: function(el) {
                //  el.lightGallery({
                //      selector: '#imageGallery .lslide'
                //  });
                // }
            });

            $(window).scroll(function() {
                checkAnimation(flatDesc);
                checkAnimation(flatInfoList);
                checkAnimation(flatInfoEstateAgent);
                checkAnimation(flatLocation);
                checkAnimation(estateAgent);
            });

            // SnazzyMap
            var latitude = '<?php echo $flat["latitude"] ?>';
            var longtitude = '<?php echo $flat["longtitude"] ?>'; 
            initMap(latitude, longtitude);

            $("#estate-agent .button-green").on("click", function() {
                $("#estate-agent .contact-form").slideToggle("slow");
            });
        });
    </script>
    <div id="flat-single" class="container-fluid page">
        <div class="row">
            <div class="parallax-bg" style="background-image: url('<?php echo $flatImage?>'); margin-top: 0;">
                <div class="gradient-diamond"></div>
            </div>
            <div class="container">
                <div class="row">
                    <div id="flat-desc" class="col-sm-12 anim-1s">
                        <h1 class="ft-green text-center mar-top-50"><?php echo $district.", ".$flat["cim"] ?></h1>
                        <h3 class="ft-green text-center"><?php echo $actual ?></h3>
<!--                        <h2 class="ft-green text-center" style="margin-top: 0px;"><?php echo $district ?></h2> -->
                        <div class="row" style="position: relative; overflow: hidden;">
                            <div id="flat-info-list" class="col-sm-6 text-center mar-top-50 anim-1s">
                                <ul>
                                    <li><?php echo $lang["flat-single-price"].": " ?><span class="ft-green"><?php echo $price ?></span></li>
                                    <li><?php echo $lang["flat-single-size"].": " ?><span class="ft-green"><?php echo $flat["meret_nm"] ?>m<sup>2</sup> </span></li>
                                    <li><?php echo $lang["flat-single-rooms"].": " ?><span class="ft-green"><?php echo $flat["szobaszam"] ?></span></li>
                                    <li><?php echo $lang["flat-single-level"].": " ?><span class="ft-green"><?php echo $flat["emelet"] ?></span></li>
                                </ul>
                            </div>

                            <div id="flat-info-estate-agent" class="col-sm-6 mar-top-50 anim-1s">
                                <div class="row">
                                    <div class="col-sm-6 text-right">
                                        <img class="img-responsive" src="img/nincs_kep.jpg">
                                    </div>
                                    <div class="col-sm-6 text-left">
                                        <h2 class="ft-green" style="margin-top: 8px;"><?php echo $flat["nev"] ?></h2>
                                        <h3 class="ft-green">
                                            <?php echo $flat["pozicio"] ?>
                                        </h3>
            <!--                                <h4 class="ft-green">Budapest</h4> -->
                                        <br>
                                        <h4 class="ft-gray"><?php echo $flat["telefonszam"] ?></h4>
                                        <h4 class="ft-gray"><a href="mailto:<?php echo $flat["email"] ?>"><?php echo $flat["email"] ?></a></h4>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div id="flat-desc-txt" class="row">
                            <div class="col-sm-12 text-center mar-top-50">
                                <p style="font-size: 1.2em;">
                                    <?php echo $description ?>
                                </p>
                            </div>
                        </div>
                        <div class="row mar-top-50 flat-info">
                            <div class="col-sm-12">
                                <?php if (isset($galeryImages)): ?>
                                <ul id="imageGallery">
                                    <?php foreach ($galeryImages as $img): ?>
                                    <li data-thumb="img/flats/<?php echo $img["respo"] ?>" data-src="img/flats/<?php echo $img["high_res"] ?>">
                                        <img class="img-responsive" src="img/flats/<?php echo $img["high_res"] ?>" />
                                    </li>
                                    <?php endforeach ?>
                                </ul>
                                <?php endif ?>
                            </div>
                        </div>

                        <div id="flat-location" class="row mar-top-50">
                            <h2 class="ft-green text-center" style="margin-top: 0px;"><span class="border-bot-green"><?php echo $lang["flat-single-map-location"] ?></span></h2>

                            <div id="map" class="col-sm-12 mar-top-50"></div>

                            <div class="col-sm-12 text-center mar-top-50">
                                <?php if (!empty($location)): ?>
                                <h2 class="ft-green text-center"><span class="border-bot-green"><?php echo $lang["flat-single-location"] ?></span></h2>
                                <p class="mar-top-50" style="font-size: 1.2em;">
                                    <?php echo $location ?>
                                </p>    
                                <?php endif ?>
                            </div>

                        </div>
                        <div id="estate-agent" class="row mar-top-50 anim-1s">
                            <h2 class="ft-green text-center"><span class="border-bot-green"><?php echo $lang["general-more-info"] ?></span></h2>

                            <div class="col-sm-3 col-sm-offset-3 mar-top-50">
                                <img class="img-responsive" src="img/<?php echo $assistantImage."?".time(); ?>">
                            </div>

                            <div class="col-sm-4 mar-top-50">
                                <h2 class="ft-green"><?php echo $flat["nev"] ?></h2>
                                <h3 class="ft-green">
                                    <?php echo $flat["pozicio"] ?>
                                </h3>
<!--                                <h4 class="ft-green">Budapest</h4> -->
                                <br>
                                <h4 class="ft-gray"><?php echo $flat["telefonszam"] ?></h4>
                                <h4 class="ft-gray"><a href="mailto:<?php echo $flat["email"] ?>"><?php echo $flat["email"] ?></a></h4>
                            </div>

                            <div class="col-sm-12 text-center mar-top-50">
                                <input class="button-green anim-03s" type="button" name="" value="<?php echo $lang["flat-single-contact"] ?>" style="font-size: 1.5em; padding: 15px 25px;">
                            </div>

                            <div class="col-sm-12 contact-form">    
<!--                                <h2 class="ft-green text-center"><span class="border-bot-green">Vedd fel velünk a kapcsolatot!</span></h2> -->
                                <form class="mar-top-50" name="contactform" method="post" action="send_email_form.php" enctype="multipart/form-data">
                                    <input type="text" name="name" class="ft-green" placeholder="<?php echo $lang['kapcsolat-nev'] ?>">
                                    <br><br>
                                    <input type="text" name="from" class="email ft-green" placeholder="<?php echo $lang['kapcsolat-email'] ?>">
                                    <br><br>
                                    <input type="text" name="subject" class="ft-green" placeholder="<?php echo $lang['kapcsolat-targy'] ?>" value="Érdeklődés a(z) <?php echo $flat["cim"]." ".$flat["meret_nm"]."m2-es" ?> lakással kapcsolatban">
                                    <br><br>
                                    <textarea name="message" class="inp-textarea ft-green" placeholder="<?php echo $lang['kapcsolat-uzenet'] ?>" rows="10">
Kedves <?php echo $flat["nev"] ?>!

A következő kérdésem lenne a lakással kapcsolatban:

</textarea>
                                    <br><br>
                                    <input type="submit" name="submit" value="<?php echo $lang['kapcsolat-kuldes'] ?>" class="submit">
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

<?php include("footer.php"); ?>

1 个答案:

答案 0 :(得分:0)

看起来这是从服务器加载的页面花了这么长时间。无论是什么在另一端查找ID似乎都很慢。我会看一下整体服务器的速度,但也要确保你的数据库上有索引,这样可以加快速度。