第一个请求要花时间才能达到服务器API方法,因为它会在启动任务中预先构建服务,有人可以建议我减少第一个请求在IIS中发布后的初始延迟。
// This method gets called by the runtime.
// Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IContactService, ContactService>();
services.AddTransient<IPersonService, PersonService>();
services.AddTransient<IDashboardService, DashboardService>();
services.AddTransient<IEmployeeService, EmployeeService>();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "ClientApp/build";
});
}
需要花费100多个时间来进行预建。
答案 0 :(得分:1)
答案 1 :(得分:0)
这可能是您的IIS配置存在的问题,因为应用程序池是从不活动中回收的。
如果在高级设置下设置了ApplicationPool的启动模式,则应在每次调用时准备使用它,除非您恰好在回收时调用它发生。
可以通过以下方式找到它:
对于后一问题,它会在需要时(每29小时)进行回收,您可以将回收安排在一定的时间进行,以免干扰。在同一高级设置屏幕上:
Change Regular Time Interval (minutes)
到0 Specific Times
,然后单击显示时间跨度[]数组的...
。