A question I’ve received multiple times is “Why is it taking so long to load Sitefinity the first time after I recycle my application pool/restart my server/make change in my web.config file, etc"?
The answer is simple – it’s how .NET works!
Sitefinity is an ASP.NET web application. As such, the first time a user requests a resource from the website ASP.NET automatically compiles the application code and any dependent resources. Furthermore any application pool recycles, modifications in the source code or the top-level items of the application (such as the web.config, global.asax, etc) would cause ASP.NET to recompile the source files into assemblies. More info about ASP.NET’s application lifecycle can be found on MSDN.
So is there a way after a scheduled application pool recycle or change in the code for avoiding the first user to have to wait until the application recompiles? The answer is – yes, there is! It’s called application warm-up. It’s all about forcing the application to reinitialize after it has been restarted. It’s not something you do from within Sitefinity, just as recompilation doesn’t happen because of Sitefinity.
There are a couple of handy tools that work like a charm to achieve the required results:
1) Application Initialization for IIS 7.5 - IIS Application Initialization for IIS 7.5 enables website administrators to improve the responsiveness of their Web sites by loading the Web applications before the first request arrives.
Well, after giving it a try, it does do what it says on the tin! After installing it on your server, you can either configure forcing individual applications to reinitialize after an application pool recycle/server restart, or configure the applications to reinitialize after a soft reset (edits in web.config, etc).
In order to set up application warm-up after a recycle, you need to edit your %windir%\system32\inetsrv\config\applicationHost.config file and locate your <system.applicationHost> block. Edit the settings of the application you’d like to automatically initialize after a restart like this:
Next, under the <sites> block, configure the serverAutoStart property of your website like this:
" MyApplicationPoolName "
This way, even if you recycle your application pool on regular intervals or at a specific date/time, it will initialize automatically afterwards and initial load time will be normal for the first user that hits your website afterwards.
2) Keep Alive Service For IIS 6.0/7.5 – the keep alive service requires no configuration, i.e. you install and forget about it. It monitors your IIS metabase and keeps all websites warm and quick.
So far I’ve been experimenting with these two and they seem to work pretty well.
Feel free to add your own tips, tricks and suggestions to the list!