Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
389 views
in Technique[技术] by (71.8m points)

c# - ASP.NET MVC - Slow initial load

I've recently created an asp.net mvc web application and published it online.

When first loading the website you should find that it takes around 10-15 seconds for it to actually show, however after it's clicked once, it loads as quickly as I expect the second time round. I'm just wondering if anyone may have an idea of why the website is taking so long?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I also had same problem, with slow first loading asp.net mvc sites, finally I found the best way for load a site, extremly fast in first load.

My solution is for windows server 2008 r2 and IIS 7.5, but in upper windows servers and upper iis versions also work, with some simple diferences.

First of all, you must set startMode of your application pool to always running, this will prevent your application pool from sleeping, after some time. (in my case just this step changes my sites first load from 45-55 seconds to about 8-12 seconds).

in step one, there is no first request for your website, for preloading your website, we need another step, that is by installing Application Initialization module for iis7.5 from here

in step two, you must set preloadEnabled=true for your website, this option is what application initialization added to site settings.

For more information and how you can set these option please refer to this blog post: http://blogs.iis.net/wadeh/application-initialization-part-2

after step two, my web site loads in just 1-3 seconds.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...