0

I developed my first Question & Answer web project (ASP.NET MVC).I hosted it in Godady. When i click it first time, the web site loads too slow. Firstly i did something below to increased performance but they are not more effective. Web site is still loading about 20 seconds. What should i do increase performance? Please help.

Web site link --> http://www.annedenalhaberi.com/

  • I used bundle config for CDN like

 public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.UseCdn = true;
            BundleTable.EnableOptimizations = true;
            bundles.Add(new ScriptBundle("~/bundles/jquery", "http://code.jquery.com/jquery-3.2.1.min.js"));
            bundles.Add(new ScriptBundle("~/bundles/bootsrap_css", "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"));
            bundles.Add(new StyleBundle("~/bundles/bootsrap_js", "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"));

            bundles.Add(new StyleBundle("~/bundles/mystyle_css").Include(
                      "~/Content/Styles/style.css"));

        }
  • I put css bundles into head tag and js bundles after the html tag

<html>
  <head>
   .....
     @Styles.Render("~/bundles/bootsrap_css")
      @Styles.Render("~/bundles/mystyle_css")
  </head>
  <body>
  ......
  </body>
</html>

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootsrap_js")
  • 3
    Possible duplicate of [ASP.NET MVC - Slow initial load](https://stackoverflow.com/questions/21150237/asp-net-mvc-slow-initial-load) – TryingToImprove Jan 31 '18 at 11:29
  • 3
    It took less than a second for me to load, and I've never visited it before. It looks to me like you're experiencing the slow load that you get when IIS has to load a site for the first time (making changes to the site make it a new site, in the eyes of IIS). As long as you, as the developer, hit the site every time you update it then it shouldn't be an issue. The only issue would be if you were having automated updates and not verifying the site afterwards, but then you're asking for trouble anyway. – Reinstate Monica Cellio Jan 31 '18 at 11:32
  • Also, if it's a .Net web site (as opposed to a .Net web application) then IIS has to actually recompile the site when you change it. I worked on a legacy site that used to take up to a minute to run after every update, but was <100ms after that. – Reinstate Monica Cellio Jan 31 '18 at 11:34
  • Thank you for your answer Archer. Yes i know when updating web site the first load is too slow. Bu this issue not same. Today ı didnt any update. But shortly before i clicked it , it took 16.5 second. I think when nobody enters the site for a certain period of time, and then clicked it i,loading slow, otherwise so fastly. Is it possible read from disk or memory cache? – Aylin Çelik Jan 31 '18 at 12:07
  • Are you using entity framework? I know when you call entity framework for first time it takes time to initialize things. – Masoud Keshavarz Jan 31 '18 at 12:25
  • Yes, i am using EF. – Aylin Çelik Jan 31 '18 at 12:56

2 Answers2

0

The slow response on your first request is because of design of IIS. IIS starts a site or application pool only once a request is received. And after a fixed amount of time if there are no new incoming requests coming, IIS stops the site again.

Check for the following thing for better first time load of the application.

  • Make sure that your views are pre-compiled. More details
  • Enable the autostrat feature on the IIS server . More details
  • Configure your PreWampUp module More details
  • Make sure that all your static assets are getting cached
PSK
  • 17,547
  • 5
  • 32
  • 43
0

Your website loads slowly because it's in a shared app pool on the server. That means that after some time it will go to "sleep" if no requests are made to it. So the next time your app gets a request, the app needs to be reloaded again.

Remember that it's not just serving static content, it's a program. So if you want it to always be running then you usually have to upgrade your subscription or/and run it in your own server.

Johan Herstad
  • 672
  • 7
  • 15
  • 1
    Yes, shared app pool caused the problem. So I added a scheduled job that is sending a request in a period to keep alive the application. Now there is no problrm. Site is so fast – Aylin Çelik Feb 01 '18 at 14:32
  • yes, haha. I also had that problem because my site had so few visitors that the server kept shutting it down. Very few normal hosting solutions offer a "keep alive" option. I see your site loads instantly for me, looks good! – Johan Herstad Feb 02 '18 at 07:55