Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Initial load of ALL pages slow after build

After building an MVC web application, I'm used to experiencing a slow load time for the very first web page that's accessed, and I know why this happens, but I'm also noticing that the load time is slow for the initial access of every single web page.

As an example, here are the load times for my home page under various conditions. The home page does not make any database calls:

  • Built project and loaded hope page (first web site hit, and first home page hit): 10.31 sec (expected)
  • Built project, loaded contact page (first web site hit), and then loaded home page (first home page hit): 757 ms (not expected)
  • All subsequent load times for home page (2nd, 3rd, 4th, etc. home page hits): 4 ms (expected)

I have reproduced these same results for all web pages, not just the home page. I.e., if you replace "home page" with "about us page" and "contact page" with "faq page" the load times will be nearly exactly the same as above.

These number are for my local environment, and if I push my project to the production environment, they skyrocket, and the initial load of every page is dozens of seconds.

What's interesting is that I can only remember this starting to happen a few days ago. For the last several months, from what I can remember, the initial web site load was always slow, but after that, all pages would load very quickly on their initial load.

What is causing the slow initial load time of every page?

like image 614
StronglyTyped Avatar asked Jan 15 '16 15:01

StronglyTyped


People also ask

Why is my website loading slow only for the first time?

A large volume of unoptimized images is usually the most common reason behind website slowness. High-resolution images can consume lots of bandwidth while loading. Uploading larger sized images and then scaling them down can unnecessarily increase the size of your web page – causing your website to load slowly.

Why are my pages loading so slow?

The web pages will be loading slow if there's something wrong with your network. High traffic, limited bandwidth, and data restrictions will affect the loading speed greatly. Unsatisfactory server performance and location will also slow down the loading process.

How do I fix slow loading pages?

If your website is loading slow, you can speed it up by using faster hosting, page builders, plugins, and images. Configuring a caching solution and CDN should also help, plus optimizing third party scripts like Google Fonts. Finally, make sure to clean you database and use PHP 7.4.

Why does my blog take so long to load?

The most common reasons your Wordpress site is slow to load are: Slow or poor quality hosting that doesn't match your level or traffic or site. No caching or caching plugins in place. You have a high traffic site but no content delivery network (CDN) to reduce the load on the hosting.


1 Answers

The application pool needs time to build the libraries before it can begin processing them. This can be speed up by using some kind of script. It also depends on whether you're using a website or a web application project. A website for every page the very first hit is slow and each new page hit has an extra compile time. Web application projects are precompiled should be little faster, but the libraries still need to be loaded up. The more libraries and tools you have the worse this hit tends to be.

You could also looking for IIS Auto-Start feature and setup it on your server may help speed up the process. By default Application pool gets shutdown in case of user inactivity default value of 1740 mins. You can also disable idle TimeOut by setting to 0 can help a lot.

My best bet is using Application Initialization plugin to get better performance http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-application-initialization

like image 78
DarkVision Avatar answered Sep 29 '22 19:09

DarkVision