Html代码比. ttfb大更简单


Html code more simple than that ..TTFB Large

我有下一个代码:

<table id="tabel_linie_<?php echo $id_linie ?>
<thead>
    <tr>
        <th>
            <style="text-align:left" <h4>Linia
                <?php echo $nume_linie ?>
                </h4>
        </th>
        <th>Referinta</th>
        <th>Cantitate OK</th>
        <th>Numar Operatori</th>
        <th>Cantitate NOK</th>
        <th>Ora Inceput</th>
        <th>Ora Sfarsit</th>
        <th></th>
    </tr>
</thead>
<tbody style="text-align: left">
    <?php if (!isset($valori_vechi)||($valori_vechi==false)) { ?>
    <tr>
        <td><strong><?php echo $nume_linie ?></strong>
            <input type="hidden" value="<?php echo $id_linie ?>" name="id_linie[]" />
        </td>
        <td>
            <select name="referinta[]" style="height:30px">
                <option value="0">--Selecteaza referinta--</option>
                <?php 
                  foreach ($referinte_linie as $referinta) { 
                    echo "<option value='".$referinta->id_produs."' >"; 
                    echo $referinta->referinta.$referinta->index_produs; 
                    echo "</option>"; 
                  }
                ?>
            </select>
        </td>
        <td>
            <input style="width:60px;border:1px solid green;text-align:center;padding-top:5px;padding-bottom:5px;height:16px" type="text" value="" name="cantitate_ok[]" />
        </td>
        <td>
            <input style="width:60px;border:1px solid #999;text-align:center;padding-top:5px;padding-bottom:5px;height:16px" type=text " value=" "name ="numar_operatori[] "/></td>

此代码从数据库中调用若干行,然后对每行调用"referinta",这对所有选定的行都是相同的。

问题是打开页面需要很长时间。我有超过15秒的TTFB

有谁知道如何使它进行得更快吗?

long TTFB是一个服务器端问题。改进你的html是没有用的。

通常表示服务器花费太长时间来构建响应。

这可能有很多根本原因:

  • 错误SQL查询
  • <
  • 坏代码/gh>
  • 等。

试着找到罪魁祸首,祝你好运:)

提示:这里你的PHP代码似乎很好,我认为这是你的SQL查询,需要太长时间来执行

还要注意你的HTML代码是错误的:

  • 您没有关闭table元素:<table id="tabel_linie_<?php echo $id_linie ?>
  • 你有一个样式元素在你的身体(这是不好的做法)没有结束标签(>):

    <th>
        <style="text-align:left" <h4>Linia
            <?php echo $nume_linie ?>
            </h4>
    </th>
    

Web前端:

检查HTML是否完全有效。要缩短HTML,请使用CSS类。如果每一行都有相同的<select>...</select>与许多选项加载它们一次动态:搜索键:AJAX+JavaScript。

后端:

检查SQL。可能需要一个额外的索引,查询会更智能一些。

可能是表的分页