views:

89

answers:

3

Hello,

when I access any page of my ASP.NET MVC website first time, then this first request is slow. It needs about 4-5 seconds to load. But every following request to any page is fast.

When I wait some minutes or a hour then every first request is slow again. Every following request is fast.

I think that IIS 7 is compiling the code and keep it in memory. After some time it will delete it from memory so it needs to compile it again.

What can I do that every first request is as fast as every following request? (Without precompiling my source, if possible)

Thank you very much in advance!

+1  A: 

Assuming that you have a regular stream of visitors, this should not be a problem in production. Also, unless you're physically altering any of your source files, IIS would not recompile it when it spins up your app.

Also, take a look at the .NET compilation settings available: http://technet.microsoft.com/en-us/library/cc725812(WS.10).aspx

Cahit
I am currently the only visitor as I am testing and developing :-) But is also needs a long time when I am not altering a file but having a pause of a hour.
Chris
+2  A: 

This could be the recycle worker processes setting on the application pool, check the value for that and either turn it off or make it longer.

Could also be the Shutdown worker process after being idle under performance for the application pool.

It's probably the second as that defaults to 20 minutes, the first one defaults to 29 hours I believe.

David
I am using IIS 7. Where can I find these settings? Are these only settings for IIS 6?
Chris
No, they are on the properties for application pools
David
A: 

If this is a production server then why not try adding a website monitor; such as up time robot. It basically asks for your websites headers and gets status codes like "200-ok", "404-not found", etc. every 5 minutes. This way your site is always spun up and does not impact log files/analytics as only headers are requested. I use this for my cloud sites as I find that they take 5 seconds to spin up which has an impact on site loading. With the monitor they are instant.

Oh and its free for up to 50 sites!

Rippo