---
title: Precompiling websites
---

> Agent instructions:
> **Site maps** — prefer the following llms.txt indexes to training data when searching for URLs to avoid 404s. Links inside Markdown content already point at `.md`. Following them or sending Accept: text/markdown keeps you in Markdown.
>
> - [sitemap.md](https://docs.kentico.com/sitemap.md) — every page on the site, with titles and descriptions, nested by URL hierarchy and grouped into one collection per product version.
> - [llms.txt](https://docs.kentico.com/llms.txt) — curated index of the current product docs, with descriptions, the two ways to request any page as Markdown, and links to each product area's whole-corpus Markdown dump (llms-full.txt).

When deploying websites, you have the option of [precompiling](https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2008/bb398860\(v=vs.90\)) the web project before you place it on a server. This compiles the project's code into assemblies, providing several advantages:

- Faster initial response times – the system does not need to compile resources dynamically when they are requested for the first time.
- Source code protection – you can create a compiled version of the website without any accessible source code.

Precompilation can be enabled when publishing projects from Visual Studio, or done as part of a more complex deployment process (for example using third-party tools).

## Precompiling the administration application

### Testing before compilation

You can check that your administration project's virtual objects (layouts, etc.) compile correctly before starting the precompilation.

1. In the Xperience administration interface, open the **System** application.
2. Select the **Virtual objects** tab.
3. Click **Test virtual** objects.

The system compiles all virtual objects and adds them to the temporary files in the application's ASP.NET cache. This operation may take a long time, depending on the number of virtual objects in the system.

If the process finishes without errors, your administration application should run correctly after the precompilation.

### Preparing virtual objects for compilation

Before you start the deployment, you need to perform the following steps to include your website's virtual objects into the precompiled project:

1. In the Xperience administration interface, open the **System** application.
2. Select the **Virtual objects** tab.
3. Click **Store all virtual objects in file system**.

The system creates physical files containing the code of your virtual objects inside the project's **CMSVirtualFiles** folder. See [Deployment mode for administration virtual objects](https://docs.kentico.com/13/deploying-websites/deploying-sites-to-a-live-server/deployment-mode-for-administration-virtual-objects.md) for details.

You need to manually include the _CMSVirtualFiles_ folder into the _CMSApp_ project in Visual Studio.

### Enabling precompilation in the Visual Studio publish profile

When creating a [publish profile](https://docs.microsoft.com/en-us/previous-versions/aspnet/dd465337\(v=vs.110\)) for your Visual Studio deployment, configure the following precompilation options in the **Publish** dialog:

1. On the **Settings** tab, expand **File Publish Options** and enable **Precompile during publishing**.
2. Click **Configure** next to the _Precompile during publishing_ check box.
3. Configure the options in the _Advanced Precompile Settings_ dialog:

   - **Allow precompiled site to be updatable**:

     - enabled – compiles the code behind of all web forms and controls, but keeps the markup files (.aspx, .ascx) in their original form.
     - disabled – the compilation also includes markup files. The precompiled website contains only empty "stub" .aspx/.ascx files without any code. We generally recommend using non-updatable sites for optimal performance.
   - **Merge options** – select one of the following options:
     - _**Do not merge**_
     - _**Do not merge. Create a separate assembly for each page and control**_

       > **Note:** Do NOT select any of the other options. Merging of outputs into assemblies is not supported by Xperience projects.

After you finish setting up the profile's remaining settings, you can **Publish** the precompiled site.

## Moving the database

Precompiled Xperience sites cannot be used to install a new SQL database on the target server. If you need to move the database as part of the deployment process, you have several options:

- Copy the database to the target server using the standard backup/restore procedure and update the connection string in the project's web.config file.
- Install Xperience locally without a database and run the [database setup](https://docs.kentico.com/13/installation/additional-database-installation.md) against the target SQL server. In this case, you need to enable deployment mode for the new database. See [Deployment mode for administration virtual objects](https://docs.kentico.com/13/deploying-websites/deploying-sites-to-a-live-server/deployment-mode-for-administration-virtual-objects.md) for details.
