This article was created in response to a support issue logged with K2. The content may include typographical errors and may be revised at any time without notice This article is not considered official documentation for K2 software and is provided “as is” with no warranties.
When there is a requirement to improve the initial load time of K2 SmartForms Forms and Views
Herewith the information and instructions on warmup options available with the scripts attached that are mentioned in the document attached. I also provide the exact settings and Web.config keys that are required to enable the Smartforms 4.7 Pre-Caching, what it covers and how to setup logging to verify that this Pre-Caching is working as expected.
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 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
2. Idle Time-out (minutes) - 1440
3. Idle Time-out Action – Suspend
The above settings should prevent slow startup each day since the app 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 SmartForms 4.7. warmup:
Ensure that the relevant forms and views are checked-in, else the pre-caching won’t work.
In IIS Manager on the K2 site and the Runtime site ensure that Preload is enabled in Advanced Settings.
Right-click on Site > Manage Website > Advanced Settings
In SmartForms Runtiime Web.config (C:\Program Files (x86)\K2 blackpearl\K2 SmartForms Runtime\Web.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" />
<add key="Forms.Warmup.PreCache.FormNames" value="Display TestList;Edit TestList; " />
Note: 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" />
To verify if pre-caching is working as expected, you can enable K2 SmartForms Logging:
Add the C:\Debug folder and set full permissions for authenticated users
<add key="TraceFilter" value="FormRuntime,Performance,PerformanceSummary"/>
<add name="ExtendedExceptionDetail" value="True" />
<add name="EnableTracing" value="true" />
<add name="MessageTypeToTrace" value="4" />
<add name="TracingToFile" value="true" />
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 occured during the pre-cache. The specified form/view should be listed in the logs.
Alternative Powershell warmup scripts:
There are also custom Powershell scripts available that can schedule IIS warmup based on when App Pool Recycling occurs. This article explains such a setup:
The above Powershell scripts will not be effective when attempting to cache forms that are loading using iFrames.
Also have a look at the IIS Application Initialization Extension here:
Slow performance due to network communication delays and/or authentication related issues will not necessarily be resolved by the SmartForms 4.7 pre-caching or the Powershell warmup scripts. In this case the network and/or user authentication and permission settings will have to be inspected to understand the cause of the delays.