Implement a Warmup service plugin

In this tutorial, you implement a custom Warmup service plugin with High priority that enables you to specify a list within a text file with exact URLs of pages you want request during system restart.

  1. Create the text file, for example, WarmupUrls.txt, with the absolute URLs that are to be requested during warmup.
    The URLs need to be separated by a new line, for example:
    • http://my-site.com/Home
    • https://my-site-2.com/About
  2. In the SitefinityWebApp project, create a new folder and name it Warmup.
  3. Create a class UrlsPlugin.cs
  4. In the UrlsPlugin class, paste the following code:

Next, you add the plugin configuration in the backend or on the file system. Refer to the following sections. 

Add the plugin configuration in the backend

  1. Navigate to Administration » Settings » Advanced settings » Warmup.
  2. Expand the Warmup node and then the Plugins node.
  3. Click Create new and enter values the following fields:
    • Name: URLs Plugin
    • Type: SitefinityWebApp.Warmup.UrlsPlugin
    • Make sure the Enabled checkbox is selected.
    • Set the priority to High.
  4. Save your changes.

As a result, you can see your newly created plugin in the Plugins node.

To add a plugin parameter:

  1. Navigate to Plugins » URLs Plugin » Parameters.
  2. Click Create new.
  3. Enter the following:
    • Key: urlsFilePath
    • Value: ~/App_Data/WarmupUrls.txt
  4. Save your changes.

After full restart of your site, the Warmup service can leverage the URLs Plugin.

Add the plugin configuration on the file system

In the ~/App_Data/Sitefinity/Configuration folder of your application create a WarmupConfig.config file and paste the following code:

NOTE: The urlsFilePath parameter specifies the application’s relative path to the text file that contains the list with absolute URLs to be requested during warmup.

Was this article helpful?