Optimizing website performance

The performance of your website depends on many factors:

  • The total number of documents on your website
  • The complexity of the website (the depth of the content tree, number of page nesting levels, number of web parts per page)
  • Custom functionality added to the application or individual sites
  • The hardware and environment on which the Kentico application and database server are running
  • The available resources if the server is shared with other applications

Tip: Finding sources of performance problems

Configure caching for your website

See the Configuring caching chapter for detailed information about the caching mechanisms available in Kentico.

The following basic settings work well for most websites:

  1. Go to Settings -> System -> Performance.

  2. Choose your website in the Site selector.

  3. Set the caching settings:

    • Cache page info (minutes): 10 or more
    • Cache content (minutes): 10 or more
    • Cache files (minutes): 10 or more
    • Client cache (minutes): 0
    • Allow client cache revalidation: yes (checked)
  4. Click Save.

Note: Caching only improves performance on the second and subsequent page loads.

Use output caching

Output caching is the best way to significantly increase the performance of pages. We recommend caching page output whenever possible, particularly for high-traffic pages.

See Caching page output for detailed information.

To enable output caching:

  1. Go to Settings -> System -> Performance.
  2. Check Enable output caching.
  3. Save the settings.
  4. Set up output caching for individual pages in Pages -> Edit -> Properties -> General -> Output cache.

Note: You may need to take additional steps to ensure that cached pages do not display outdated content.

Configure file storage and processing

Loading files from the database is a demanding operation. Storing files on the server’s file system provides better performance in most cases:

Requirement: Your application needs to have the Modify permission for the web project directory in the server’s file system.

  1. Go to Settings -> System -> Files.

  2. Enable the following settings:

    • Store files in file system
    • Generate thumbnails
  3. Consider disabling the following settings to improve loading time of document attachments:

  4. Click Save.

See also: Storing files

Organize your website’s content in the most effective way

You can store your site’s content either in Documents, Custom tables or Media libraries. Each storage type is designed for a different type of data.

Refer to Storing data effectively for more information.

Optimize your data source components

Check the configuration of all components (web partsor controls) that load data from the database or other sources. For best practices and examples, see Loading data efficiently.

Minimize compilation requirements for pages

If your pages have long initial load times (for example after application restarts), try to reduce the number of components that need to be compiled:

  • Switch to the HTML type for page layouts that do not contain controls or inline code.
  • Use the Text / XML type for simple transformations (if the code is pure HTML or only performs basic loading of field values). For complex transformations with method calls or other advanced logic, the ASCX transformation type generally provides better performance.
  • Consider precompilation of the entire project before deploying to the production environment.

Tip - Optimizing dynamic compilation when developing web site projects

During the development of web site type projects, you may experience long compilation times and slow performance after making changes to top-level files (the Global.asax file and all files in the Bin and App_Code folders). By default, the application compiles the entire site after such changes, which can be a demanding operation.

To optimize the dynamic compilation, set the optimizeCompilations attribute of the <compilation> element in your web.config file to true.

<compilation debug="true" numRecompilesBeforeAppRestart="100" targetFramework="4.0" optimizeCompilations="true">

The dynamic compilation then only includes the files that were changed instead of the entire site.

Note: Optimized dynamic compilation improves performance, but may cause compilation errors if you change an API or object that is used elsewhere on the site. For more information, see Understanding ASP.NET Dynamic Compilation.

Check custom code

If you integrated custom code into the application (including JavaScript), please make sure it works correctly.

  • Avoid excessive database operations
  • Reuse objects whenever possible
  • Use custom caching when you load data through the API

Try to comment out your code and see if the performance improves.

Disable debugging tools

Always disable all Kentico debugging tools before deploying websites to the production environment:

  1. Go to Settings -> System -> Debug.
  2. Check the Disable debugging setting.
  3. Click Save.

Disable output filters

Applying output filters adds steps to the processing of pages, and may slow down the website. If the output code of your pages is valid without filtering, you can disable the filters:

  1. Go to Settings -> System -> Output filter.

  2. Choose your site in the Site selector.

  3. Type the / character (forward slash) into the following settings:

    • Excluded output form filter URLs
    • Excluded resolve filter URLs
    • Excluded XHTML filter URLs
    • Excluded HTML5 filter URLs
  4. Save the settings.

The system excludes all pages on the website from the output filter. If you resolve your performance issues by disabling the output filter, but need to keep the functionality to produce valid code, please contact Kentico support to find a workaround.

Limit scheduled tasks

You can conserve system resources by limiting the execution of scheduled tasks:

  • Disable all unnecessary tasks
  • Increase the execution intervals of tasks
  • Run tasks using the external Windows service if possible

Enable minification and compression of resources

Use code minification and compression to reduce the size of CSS and JavaScript resources. This helps limit the volume of traffic between the server and clients.

Increase the application pool Idle Time-out in IIS

If your website has periods of inactivity (no requests for over 20 minutes by default), users may experience long delays when first opening the site. To prevent this, set the Idle time-out (minutes) property of your IIS application pool to a higher value:

  1. Open your Internet Information Services (IIS) Manager console (Start -> Control Panel -> Administrative tools -> Internet Information Services (IIS) Manager).
  2. Select <machine>/Application Pools.
  3. Right-click the application pool used by the Kentico application and select Advanced Settings.
  4. Enter the required value into the Idle Time-out (minutes) property in the Process Model section.

Scale the hosting environment

If performance is still not satisfactory after you have taken all possible steps to optimize your website, you may need to upgrade your hosting environment:

  • Scale out - add more servers hosting the same content, and set up a web farm
  • Scale up - upgrade the hardware of your server

One way to create an easily scalable website is to deploy your instance to cloud hosting.