Sitefinity CMS has a custom command-line tool for precompiling pages - Telerik.Sitefinity.Compiler.exe. It compiles the generated markup, retrieved from the markup service.
Since Sitefinity CMS pages are dynamically generated, their entire markup is retrieved via a service endpoint, which is available at /restapi/markup. From that endpoint, the markup for a requested page in a specific language is retrieved and prepared for compilation.
How the precompiler tool works
When a frontend page is requested, Sitefinity CMS tries to load the page from the precompiled assembly, if present. If the page is found in the assembly and its version matches the one that the page in the assembly was built with, the page from the assembly is loaded and served. If there is no match, the page is compiled dynamically.
Once the page's version changes, it will no longer be loaded from the precompiled assembly, but, instead, from a dynamically generated satellite assembly.
: The version of the page changes when one of the following actions occurs:
- The page is published.
- You edit any of the master pages that the page is based on, including any master pages which master pages are based on.
NOTE: If you apply a change to a template, on which many pages are based, all of the pages based on it will have a different version and will be no longer loaded from the precompiled assembly.
Download and run the tool
Download Sitefinity CMS precompiler tool and extract the .zip files. The tool is Telerik.Sitefinity.Compiler.exe.
For more information about the commands you can use in the tool, see Reference: Command line arguments.
RECOMMENDATION: Since the tool uses a URL to connect to the site, and to retrieve the markup, we recommend to run the tool against the site which is connected to the most up-to-date database. The application directory of the Sitefinity CMS web application should contain the most up-to-date templates, user controls, master-pages stored on the file system, as well as the most up-to-date compiled application assemblies. For example, if you have two servers – a production and a staging server, the tool should be executed against the site with the most recent database changes (production server) with the application directory of the staging server.
In order authenticate with Sitefinity CMS, the precompiler tool supports the following methods:
- Authenticate with a username, password, and membership provider.
Use the Username, Password, and MembershipProvider command line arguments, respectively.
The authenticated user must be an administrator.
- Authenticate with an authentication key.
Use the AuthKey command line argument and specify the authentication key.
You must have set the authentication key in Sitefinity CMS. To set an authentication key, log into Sitefinity's backend and in the main menu, click Administration » Settings » Advanced » Pages » Compilation. Set the key in the Authentication key field.
NOTE: Only one of the two authentication methods can be used at a given time. Authentication with an authentication key and the AuthKey argument has a higher priority over authentication with a username and a password.
IMPORTANT: If you are using Windows authentication, you must always use authentication key.
Antivirus software considerations
Scanning the files generated by the precompiler with certain antivirus software, may lead to an AppDomainUnloadException.
To work around this issue, you need to set the httpruntime/delayNotificationTimeout property in your web.config to a greater value, namely between 10 and 30 seconds. For more information, see HttpRuntimeSection.DelayNotificationTimeout Property.