在IIS上运行的ASP.net上的超长TTFB

时间:2019-03-20 10:10:02

标签: c# asp.net-mvc iis web-testing

我当前正在建立一个用于创建自定义计算机的网站,但是我的问题是,在家用IIS服务器上运行时,我的TTFB非常慢。我在该服务器上运行着多个网站,这是唯一一个20-30秒TTFB的网站。

我已经使用webpagetest.org来测试我的网站并获得this water fall image

但是,我然后使用VS和chrome自己的开发工具对我的网站进行了调试,而我的water fall here给了我1秒钟的时间。我想知道如何在服务器或页面上诊断和测试可能导致此问题的问题。 这是我的主页代码段,供任何想知道的人使用- 控制器:

namespace ComputerSite.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

布局(页面中仅有的一部分没有静态内容):

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - Computers for you!</title>
@Styles.Render("~/Content/boot")
@Scripts.Render("~/bundles/modernizr")

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/ajaxgroup")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/datatables")
@Scripts.Render("~/bundles/tawk")
@if (Request.IsAuthenticated)
{
    string text = UserHelper.GetUserEmail(User.Identity.Name), key = "MY APIKEY";
    System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();

    Byte[] textBytes = encoding.GetBytes(text);
    Byte[] keyBytes = encoding.GetBytes(key);

    Byte[] hashBytes;

    using (System.Security.Cryptography.HMACSHA256 hash = new System.Security.Cryptography.HMACSHA256(keyBytes)) { hashBytes = hash.ComputeHash(textBytes); }

    string hashTxt = BitConverter.ToString(hashBytes).Replace("-", "").ToLower();

    <script type="text/javascript">
        Tawk_API.onLoad = function(){
        Tawk_API.setAttributes({
        'name' : '@User.Identity.Name',
            'email': '@UserHelper.GetUserEmail(User.Identity.Name)',
        'hash': '@hashTxt'
}, function (error) {});

};
    </script>
}
@RenderSection("scripts", required: false)
</head>
<body>
@{ Html.RenderPartial("_navBar"); }
<div class="container body-content">
    @RenderBody()
    <hr />
    <footer>
        <p>&copy; @DateTime.Now.Year - Building computer for you by you!</p>
    </footer>
</div>

</body>
</html>

根据要求,我创建了一个全新的ASP.net网站并对其进行调试,由此我得到了waterfall,其加载时间为270 ms,TTFB为12ms

0 个答案:

没有答案