K2 SmartForms Performance - Warmup Options
KBS100015
PRODUCTIssue
When there is a requirement to improve the initial load time of K2 SmartForms Forms and Views (Please note: These settings are included by default with K2 Five - they do not need to be configured, as they are set correctly by default)
Symptoms
- Settings and Web.config keys that are required to enable the Smartforms Pre-Caching
- How to setup logging to verify that this Pre-Caching is working as expected.
Troubleshooting Steps
IIS Application Pool recycling and startup process impact: Warmup scripts and pre-caching
IIS Application Pool Recycling means the worker process that handles requests for that application pool is terminated and a new one is started. This is generally done to avoid unstable states that can lead to application crashes, hangs, or memory leaks.
The default K2 SmartForms Runtime Application Pool settings should be as follows:
- Start Mode - AlwaysRunning
- Idle Time-out (minutes) - 1440
- Idle Time-out Action – Suspend
The above settings should prevent a slow startup each day since the application should not have been restarted.
If a K2 SmartForms Runtime Application Pool startup process does occur when the site runs for the first time every day, this will slow down the page load. It might also be that other applications are starting at the same time, which could also slow down the first load of the K2 SmartForms page even further. Warm-up scripts are available to reduce the impact of such an Application Pool startup process if required. SmartForms Pre-Caching was introduced in the K2 Blackpearl 4.7 Release. This allows warmup functionality for all forms or for specific forms.
The following Web.config settings are required to enable this warmup functionality and to produce logs that will verify that the warmup occurred effectively for the relevant forms.
To enable the SmartForms warmup
IIS Settings
- In IIS Manager on the K2 site and the Runtime site, please ensure that Preload is enabled in the Advanced Settings.
- Right-click on Site > Manage Website > Advanced Settings
- In the SmartForms Runtiime Web.config (C:Program Files (x86)K2 blackpearlK2 SmartForms RuntimeWeb.config)
- Add the following in your web.config file in the appSettings Section to pre-cache all SmartForms Forms and Views:
<add key="Forms.Warmup.PreCache.AllForms" value="true" />
Or, to enable pre-caching for certain forms, add the following in your web.config file in the appSettings Section:
<add key="Forms.Warmup.PreCache.AllForms" value="false" />
Ensure the following keys exist and are enabled in the system.webServer section:
<applicationInitialization doAppInitAfterRestart="true" remapManagedRequestsTo="Startup_Runtime.html" skipManagedModules="false">
<add initializationPage="/Warmup.aspx" />
</applicationInitialization>
To verify if pre-caching is working as expected, you can enable K2 SmartForms Logging:
<add key="TraceFilter" value="FormRuntime,Performance,PerformanceSummary"/>
<system.diagnostics>
<switches>
<add name="ExtendedExceptionDetail" value="True" />
<add name="EnableTracing" value="true" />
<add name="MessageTypeToTrace" value="4" />
<add name="TracingToFile" value="true" />
</switches>
</system.diagnostics>
Perform an IISRESET on the K2 SmartForms Servers and refresh your browser by using Ctrl+F5. The following should be visible on the Form:

- If the above spinner does not display, the logs should be available in CSV format in the 'c:Debug' folder.
- Search for 'Pre-Cache ALL Forms' and/or 'Pre-Cache Forms' to see if any errors occurred during the pre-cache. The specified form/view should be listed in the logs.
Alternative PowerShell warmup scripts
Alternative warmup scripts may include simple PowerShell scripts that can preload a specific URL to ensure that related CSS and JavaScript is cached (also depending on browser settings). We have such a script available, this can be found here:
There are also custom PowerShell scripts available that can schedule an IIS warmup based on when App Pool Recycling occurs. This article explains such a setup:
https://www.henriksommerfeld.se/setting-up-an-iis-warm-up-script-in-an-automated-fashion/
Additionally, have a look at the IIS Application Initialization Extension here:
https://forums.iis.net/t/1176740.aspx