Solution to slow first visit of asp.net website

Time:2021-11-27

This experience takes iis8 and windows server 2012r2 as examples.

Iis8 runs on platforms above Windows Server 2012 and windows 8.

In IIS, the application pool and website exist separately, but the website must run on the premise that the corresponding application pool is started.

By default, when the application pool is inactive (no requested operation), it will be automatically recycled by IIS after a period of time.

Iis8 comes with an application initialization kit. Iis7.5 needs to search for an independent installation package for installation. IIS automatic initialization is not supported for those lower than 7.5.

The method in this experience can solve the problem of slow access to ASP. Net after a period of time.

Method / step

Install IIS application initialization function, as shown in the following figure:

Edit the startup mode of the application pool corresponding to the website. The operation path is: application pool – > application pool corresponding to the website – > right click, advanced settings – > select, startup mode alwaysrunning, as shown in the following figure:

Enable the corresponding website preload. The operation path is: Website – > corresponding website – > right click, advanced settings – > select. Preload is enabled. True, as shown in the figure below:

Set the configuration editor, write the default preload request, and open the configuration editor, as shown in the following figure:

Select system.webserver/applicationinitialization in the upper left configuration node. Other configurations are shown in the red circle, as shown in the following figure:

Add an initialization request address (the default request address for IIS initialization) to the collection. After adding, click the Apply button on the right side of the configuration interface and restart the application pool and website, as shown in the following figure:

Summary:

1. Principle description: IIS application initialization will automatically open a new program pool after the website is first created or after the application pool of the corresponding website is recycled, and start website initialization to simulate a normal request to keep the website online.

(this process can achieve the same purpose by simulating website requests with third-party tools or services)

2. Configuration Description:

(1) . enable application pool (alwaysrunning): ensure that the application pool can automatically restart after it is created or recycled for the first time.

(2) Enable website program preloading (true): ensure that the website can respond to the preloading action after the program pool is started.

(3) Configure the default preload path of the website: ensure that the program can quickly compile and reside in memory during the preload of the website after the program pool is started, so as to ensure rapid response to requests.

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support developpaer.