Pre-compilation of Pages in Sitefinity: How it Works and its Implementation
Telerik.Sitefinity.Compiler.exe
Sitefinity has a custom command line tool for precompiling pages.
Sitefinity Version: V 7.3 or Above
Pre-compilation of pages gives the following advantages:
- Pages load faster when requested for the first time
- Reduces processor load
- Minimizes the warm up time when a site is deployed.
How it Works
When a web page is requested, Sitefinity checks the page from the precompiled assembly. If the page is found in the assembly and its version matches with the requested page in the assembly, then the page from the assembly is loaded.
If no matching is found, then the page is compiled dynamically.
The tool uses a URL to connect to the site. It is always recommended to run the tool against the site with most up-to-date database and the application directory of the web application having the most up-to-date templates, user controls, master-pages stored on the file system including the most up-to-date compiled assemblies.
Generally, we use two servers for the development of websites. Staging server and Live server. Therefore, as mentioned above, it is always recommended that the tool should be executed in the live environment, as a live site is always with the most recent database and the latest files.
How to Implement
In the first step, you need to download and run the Sitefinity precompiler tool
https://sitefinitystore.blob.core.windows.net/files/Telerik.Sitefinity.Compiler.1.0.0.12.zip
The tool is Telerik.Sitefinity.Compiler.exe
The Pre-compiler tool supports two types of Authentication:
1- Authenticate with a Username and Password with Membership Provider.
For this, the user must be an administrator.
Command Line Example
Telerik.Sitefinity.Compiler.exe /url=”http:// http://localhost:51824/” /appdir=”D:\Projects\SitefinityWebApp” /username=”sfadminuname” /password=”admin@6yyg2″ /strategy=”Frontend” /membershipprovider=”Default”
URL -> URL of the web application
Appdir -> Physical path of the web application
Username -> Username to authenticate i.e. login username
Password -> Password to login
2- Authenticate with an Authentication Key.
For this, you must have to set the authentication key by logging in Sitefinity backend.
Administration – Settings – Advanced – Pages – Compilation and Set the key in the Authentication key field.
Command Line Example
Telerik.Sitefinity.Compiler.exe /url=”http://localhost: 51824″ /appdir=”D:\Projects\SitefinityWebApp” /authKey=”6%6$#7777u{9u~]k3M3Q” /strategy=”Frontend”
As we all know, compilation is always a time taking task in Sitefinity. So, we must identify the problematic pages or user controls. For this Sitefinity has a feature “precompilation logging” to trace the same. You only have to enable the feature, which is disable by default.
Also Read: How to Configure the Security Policies and HTTP Response Headers
Contributed By:
Arunodaya Kumar