The intialization module in IIS8

Remember those days when you had to wait for a web application to 'warm up'. If you had a quiet website this meant that if no-one had visited it in a while the first page load would take ages. There were various workarounds such as setting your app pools to stay alive for days but they were all working around the problem. Fortunately in IIS from IIS 7.5 the initialization (previously warm up) module has been available to get around exactly that problem. It previously used to be a separate module but as of IIS 8 it's now included.

Installing it is as simple as going to "Add roles and features" and then selecting the "Web server" -> "Application development" -> "Initialization module".

Once installed you will need to make sure that any application pools that you want to always be available have "StartMode" set to "AlwaysRunning". You can do this via the IIS GUI or through the application host config file. If you're doing it through the GUI then right click on the application pool and go to "Set application pool defaults".

Then set "StartMode" to "AlwaysRunning".

Alternatively if you want to set this through the config file it's located at %WINDIR%\system32\inetsrv\config and called applicationHost.config. Look for the following line.

<add name="Your app pool" managedRuntimeVersion="v4.0" />

Then simply amend it with a new startMode attribute set to AlwaysRunning like this.

 <add name="Your app pool" startMode="AlwaysRunning" managedRuntimeVersion="v4.0" />

For each web site that you want to keep alive within the <sites> section there will be an application element that we need to adjust. Take the root website for example.

<application path="/" applicationPool="Your app pool">

We need to tell IIS to send a fake request to the application when the app pool starts up. We can do this simply by adding the preloadEnabled attribute to true. So we'll end up with this.

<application path="/" preloadEnabled="true" applicationPool="Your app pool">

That's enough to keep web site running at all times. So whenever the web server restarts or the the web service is recycled a fake request will be sent to trigger the application to start up. We've only made the simplest use of the intialization module here but it also does allow us to to do a whole lot more. For example we can configure splash pages to be served while the application is loading, configure overlapped process recycling or even run more intensive application initialisation code if you know your application requires a lot of initialisation code to run. Fortunately these features are all well documented over at the IIS site.