File Change Notification (fcnMode): What is it and how does it affect my Sitecore Application

File Change Notification (fcnMode): What is it and how does it affect my Sitecore Application

The File Change Notification or the fcnMode is a great feature that is available in ASP.net applications. This blog provides an overview of the File Change Notification (fcnMode) and its significance to Sitecore Applications.

Although this blog post is inclined towards a Sitecore Application, I have also included basic information related to FCNMode which would be useful for plain .NET Applications too.

What is File Change Notification (fcnMode)

The File Change Notification is an inbuilt feature in ASP.net that detects the file changes from your website and automatically restarts the Application Domain. For the users who are new to Sitecore, when you publish a DLL change to your website, you will see the website taking some additional time to load. This is due to FCN which forces an AppDomain restart that causes the website to take more time to load.

There is a substantial difference between Application Pool and Application Domain:

Many times, “Application Pool” and “Application Domain” are used interchangeably, but there is a considerable difference between the two.

The Difference:

  • An Application Domain provides isolation between .NET applications running within the same process while the Application Pool provides process-level isolation.
  • Two different Application Domains may share a single-worker process (w3p) but two different Application Pools won’t share a single-worker process.
Fig: No sharing
  • It is better to use the terms Recycle with Application Pool and Restart with Application Domain to avoid confusion viz. Recycle an Application Domain and Restart the Application Pool.
  • Please note that Application Domain is a concept specific to an ASP.net application while Application Pool can be used for any type of application.
Fig: Re-Iterating!

The similarity between the two is that both Application Domain and Application Pool are used to provide Application Isolation.

Why disable the File Change Notification (FCN):

Restarting the application domain is an expensive operation for any Sitecore application and hence it would be good to disable the FCN for performance tuning. Besides it would also help in avoiding undesired App Domain restarts that might be happening in the background which may not have been reported yet. Even if you are not facing an issue related to unwanted or undesired app domain restarts, you should disable the File Change Notification to solve a problem even before it occurs.

Fig: Modern Problems!

Sitecore also recommends this step in the following article: Sitecore Tuning Recommendations.
Although this article is defined for Sitecore Managed Cloud instance, this is applicable for On-Premise setups too.

The Effect:

After you disable the File Change Notification, IIS will no longer monitor the changes other than the Web.config and the App_Config changes in your Website. Even after you deploy a DLL change, the App Domain won’t be restarted and you won’t witness any interruption in accessing your website.

How to Disable the File Change Notification?

Step 1: Add the fcnMode=”Disabled” attribute in Web.config

To set the File Change Notification, you need to make the following change in the root Web.config file. The following entry should be added:

<configuration>
    <system.web>
        <httpRuntime fcnMode="Disabled"/>
    </system.web>
</configuration>

Please note that if your root Web.config already contains the <httpRuntime> node, you need to add the attribute fcnMode=”Disabled” inside this existing node itself:

<httpRuntime targetFramework="4.8" fcnMode="disabled" maxRequestLength="512000" executionTimeout="600" enableKernelOutputCache="false" relaxedUrlToFileSystemMapping="false" requestValidationMode="4.0" enableVersionHeader="false" requestValidationType="Sitecore.Web.RequestValidators.SitecoreBackendRequestValidator, Sitecore.Kernel"/>

Note: The above Web.config entry has been taken from a Vanilla instance of the Sitecore 10.4 setup.

Important Considerations after setting fcnMode=”Disabled”

1. Add App Pool Recycle step in the Release Pipeline:

As the Application Domain wouldn’t be restarted after implementing this setting, all your newly deployed changes wouldn’t be visible on the website after deploying them right away. If you are using a CI/CD Pipeline for deployments, you must add a Recycle App Pool step in the release pipeline after deployment to each environment.

2. Manual Deployments: Mandatory App Pool Recycles after Deployment:

After any manual file deployments, the App Pool Recycle step should be performed manually. Make sure to notify your Deployment Team regarding this important step otherwise the changes from the deployment won’t be reflected on the website.

Fig: Don’t hide the Pain Harold!

Some exceptions to fcnMode=”Disabled” in a Sitecore Application:

Even after setting fcnMode=”Disabled”, the app domain would be recycled if you make changes to the Web.config file or make any modifications related to .config files in the App_Config folder. You will see the following entry in the Sitecore log file after modifying any .config file in the App_config folder:

14144 01:52:40 INFO  Config file modified: D:\Website\SC104.local\App_Config\ConnectionStrings.config
1664 01:52:40 INFO  **************************************************
1664 01:52:40 WARN  Sitecore shutting down
1664 01:52:40 WARN  Shutdown message: HostingEnvironment initiated shutdown

Please note this is only limited to the .config files inside the App_Config and not any other files.
To sum it up, the following changes trigger an application domain restart in a Sitecore application even after setting fcnMode=”Disabled”:

  • Web.config change
  • Config file changes inside the App_Config folder.

The following article on Microsoft Blogs gives detailed insights on the directories and files that are monitored when FCNMode is set to Default or NotSet. This article mentions File Change Notification to be one of the most loved and hated features of ASP.NET which is apt: File Change Notification – What exactly is monitored?

Fig: The relationship with FCN

This completes the blog post explaining the fcnMode and its significance related to Sitecore Applications. In the next blog post, I will explain the process of fetching the fcnMode value from Memory Dumps via WinDBG (Windows Debugger) which is quite critical in debugging scenarios.

Further Reading:

About me:

Vivek Anandan Venugopalan

Hi! I’m a Sitecore Certified Advanced Developer from India with 8+ years of Experience working with Sitecore. I am an avid Railfan and love Cycling and Traveling. I also have a couple of travel blogs which can be checked by clicking on the first couple of links below.

One thought on “File Change Notification (fcnMode): What is it and how does it affect my Sitecore Application

Leave a comment