开发者

Compiling time of first page load

I switched from php to asp.net for a certain project, and i've created a web application and everything went smoothly.

I have one question though....when I navigate to my website the very first time, it loads for about 8-10 seconds. I assume the code is compiling in this time. If i go back to the site, it will load very quick. However if I got back to开发者_C百科 it the next day, it will compile again.

I was wondering can anyone elaborate on what is going on? I understand it needs to compile once, but why does it do so again the next day? Is there anyway I can avoid this?

Thanks for any advice/insight,

Andrew


why does it do so again the next day?

Because of the ASP.NET Application gets restarted.

Possible reasons:

  • IIS application pool is configured to recycle the working process.
  • Other application touches (modifies or at least just rewrites) web.config.

Is there anyway I can avoid this?

Yes.

  1. Disable IIS application pool recycling.
  2. Make sure web.config is not touched by any other process. These are usually anti-vurus programs, but pretty rare case. So the 1st option is 99.9% is the cause.
  3. Precompile the ASP.NET application. This and this pages explain how.


Did you reboot your machine? Every time IIS is restarted it will need to compile your site again. Otherwise it's probably not recompiling, it's hitting the disk because the code isn't in the cache.

This shouldn't be an issue when you've deployed your app, only when you have a development setup.


You can precompile your app by deploying from VS Professional, or using the command line asp.net compiler.


Take a look at the ASP.NET Application Life Cycle:

IIS 5 & 6 - http://msdn.microsoft.com/en-us/library/ms178473.aspx

IIS 7 - http://msdn.microsoft.com/en-us/library/bb470252.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜