App Initialization upon Poll Recycle

iis | 2020-05-20

⚡ How to Initialize an IIS Application Before the First Visitor Request

This guide demonstrates how to configure IIS so that your application initializes automatically — even before the first visitor arrives.

This helps reduce perceived cold start time by ensuring the app is already running.

💡 What We Want to Achieve

We aim to spin up (initialize) the application earlier than the first user request, improving the responsiveness of the site after a recycle or server reboot.


Application Pool Configuration

Advanced Settings

To keep the application running continuously:

  • Start Mode: AlwaysRunning
  • Idle Time-out (minutes): 0

This ensures the application pool remains active and does not shut down due to inactivity.

advancedsetting

Recycling Settings

  • Fixed Interval: Set at odd hours (e.g., off-peak times) to avoid affecting user experience.

This schedules app pool recycling at specific intervals while minimizing impact.

recycleSetting

Website Configuration

Advanced Settings

  • Preload Enabled: True

This setting instructs IIS to proactively load the website when the server starts or the application pool recycles.

advancedsetting2

Steps to Configure Application Initialization

1. Install the Application Initialization Feature

Ensure that the Application Initialization feature is installed on your Windows Server or development machine.

You can install it via Server Manager > Add Roles and Features or through PowerShell.

appsetting

2. Open Configuration Editor in IIS

  • In IIS Manager, navigate to your target website.
  • Go to Management > Configuration Editor.

This is where the application initialization settings are configured.

iis

3. Configure the applicationInitialization Section

Navigate to: system.webServer/applicationInitialization

And apply the following settings:

  • Collection: Add a new record
    • hostName: Your site domain (e.g., demo.local)
    • initializationPage: Path to the page to trigger app load (e.g., /home)
    • doAppInitAfterRestart: True
    • remapManagedRequestsTo: (Optional) Path to a static HTML file for placeholder response

This configuration ensures the application initializes after a restart, optionally showing a placeholder during warm-up.

🧠 Summary

With the above settings in place, IIS will proactively load and initialize your application.

This reduces the initial load time for users and creates a smoother experience, especially after app pool recycles or server restarts.