Skip to main content
Version: 8.2

Static content bundling service

Level: advanced

Fast page loading keeps users productive and improves their experience with Creatio. To display the Creatio UI, the browser loads static content, i.e., *.js and *.css files located in the Creatio file system. *.js files can include code of "Client module" type schemas or other JavaScript data. If the browser must initially load a large amount of static content, pages take longer to open. The static content bundling service reduces the size and number of static files, so Creatio pages load faster. Out of the box, Creatio retrieves client content from pre-generated static files, i.e., the UseStaticFileContent flag in the "Web.config" file (for .NET Framework) or "Terrasoft.WebHost.dll.config" file (for .NET) is set to "true." Learn more about features of static content: Packages file content basics. If you use Creatio in the cloud, the static content bundling service is deployed out of the box.

The following table lists the ways Creatio reduces page loading time.

Way

Description

Minification

Reduces the size of *.css, *.js, and *.html files. This implies removal of commented out code as well as superfluous line breaks, leading and trailing spaces. This reduces the size of the original file by 10-20%.

Bundling, i.e., generating bundled files

Optimizes the performance by combining the static files of the same type into a single bundled file. Reduces the number of requests.

Static content bundling service executes both minification and bundling. Most web applications are delivered with minified and bundled files. Since the Creatio configuration and static content can change during the life cycle, the service runs minification and bundling automatically when necessary.

Architecture of static content bundling service​

The following table lists the bundling service elements.

Element

Description

ContentService

The service that minifies and bundles Creatio files. Deployed independently of Creatio.

ContentWatcher

A utility that interacts with Creatio files and ContentService to ensure timely minification and bundling.

To improve performance, Creatio generates minified bundled files out of the box.

The following figure shows the bundling service flowchart.

The following figure shows the bundling service workflow.

ContentService​

ContentService can be paired with ContentWatcher or work independently. If the ContentService works independently, access the endpoints manually or using a third-party automation, for example, when deploying or updating Creatio. Learn more: ContentService endpoints.

The bundling service does not require a change in the ContentService configuration to work correctly. Out of the box, the bundling service is configured optimally, but you can change the settings to boost performance or enable additional functionality. Learn more: ContentService settings.

ContentWatcher​

ContentWatcher works as follows:

  1. Watches for changes to the "_MetaInfo.json" file that Creatio changes when static content is updated.
  2. Sends a notification to ContentService about a pending bundling and passes the appropriate parameters to the service.

ContentWatcher can track changes to any file, send a notification to any URL, and monitor multiple Creatio instances. To orchestrate Creatio, ContentWatcher, and ContentService correctly, configure ContentWatcher. Learn more: ContentWatcher settings.

Interaction between bundling service elements and Creatio​

The following figure shows the interaction diagram of ContentService, ContentWatcher and Creatio that uses common settings and is deployed using the default configuration.

Deploy the static content bundling service​

Deploy the static content bundling service using Docker. Learn more: official vendor documentation (Docker).

1. Perform preliminary setup​

  1. Deploy a physical or virtual server on a Linux machine. We recommend using stable versions of Debian or Ubuntu. The server serves as the host machine for the bundling service elements.

  2. Install Docker. Instructions: Install Docker (user documentation).

  3. Provide the server access to files in the "/conf" directory of the current Creatio instance. Skip this step if you deploy the bundling service on the same server as Creatio. If you use a dedicated server to deploy the bundling service:

    1. Obtain read and write access to the "/conf" directory.
    2. Make the "/conf" directory available on the server dedicated to deploying the bundling service, for example, over a network using the NFS protocol.

2. Install bundling service elements​

The installation procedure differs depending on whether the server that hosts the bundling service has internet connection.

Install bundling service elements for a server that has internet connection
  1. Contact Creatio support to obtain the following:

    • Read access to the private Creatio image repository (https://registry.creatio.com).
    • Tags of the latest versions of the bundling service elements (content-service and content-watcher).
    • Configuration files of the bundling service.
  2. Run the docker login https://registry.creatio.com -u={Login} -p={Password} command to log in to the private Creatio image repository.

    Where:

    • {Login} is the user login to the private Creatio image repository.
    • {Password} is the user password to the private Creatio image repository.
Install bundling service elements for a server that has no internet connection
  1. Contact Creatio support to obtain the following:

    • *.tar archives that include Docker images of the latest versions of the bundling service elements (content-service and content-watcher).
    • Configuration files of the bundling service.
  2. Place the obtained archives on the server where the bundling service is deployed.

  3. Run the following commands to upload Docker images from the file system on the server to the local Docker cache.

    docker load -i content-service.tar
    docker load -i content-watcher.tar

    If you use an internal storage of Docker images, upload archives to the storage.

As a result, the bundling service elements will be ready for deployment.

  • If the server has internet connection, Docker will download the elements from the private Creatio image repository automatically.
  • If the server has no internet connection, Docker will use the elements from the local Docker cache.

3. Set up the bundling service​

  1. Place the configuration files of the bundling service into an arbitrary directory on the server, for example, "/opt/services." Creatio support provides the configuration files when you request access to the bundling service elements. Make sure the directory includes the following configuration files.

    Configuration file

    Description

    etc/content-watcher/appsettings.json

    Configuration of the ContentWatcher utility.

    docker-compose.yml

    Configuration of the Docker Compose utility.

    .env

    A list of environment variables to launch the bundling service elements.

  2. Specify the following variables in the ".env" file.

    Variable

    Description

    DOCKER_REGISTRY

    Path to the registry of Docker images. If you deploy the bundling service from local cache, leave the variable blank.

    DOCKER_TAG_SERVICE,
    DOCKER_TAG_WATCHER

    Versions (tags) of the content-service and content-watcher images provided by Creatio support. We recommend specifying the latest version of the content-service image.

    ContentPath

    Path to the "/conf" directory on the server that hosts the bundling service. Docker Compose makes this directory available in the container.

  3. Specify the following settings in the "etc/content-watcher/appsettings.json" file.

    Setting

    Description

    ContentServiceUrl

    ContentService endpoint to call when ContentWatcher detects changes. The endpoint pattern is as follows: {ContentService Url}/process-content.

    ContentWorkers

    Setting block for each Creatio instance that ContentWatcher serves. Specify Name, Directory, and ContentWorkerArguments for each instance.

    If ContentWatcher and ContentService are deployed on Linux (including Docker) and the Creatio file system is shared with ContentWatcher and ContentService, specify the paths to the directories where the Creatio file system is available in the container in the Directory and ContentPath settings. For example, if the "/conf" directory of the Creatio instance is built-in into a container in the "/app/content/" path, specify "/app/content/" in the Directory setting and "/app/content/content" in the ContentPath setting. Learn more about other settings: ContentWatcher settings.

    The following example shows the "appsettings.json" file for Creatio on-site.

    "appsettings.json"
    {
    "ContentServiceUrl": "http://host.docker.internal:5001/process-content",
    "ConfigurationRefreshInterval": "86400000",
    "DefaultFileFilter": "_MetaInfo.json",
    "FileEventWatcher": {
    "RetryFileWatchingDelay": "180000",
    "MaxFileWatchingRetries": "20"
    },
    "ContentWorkers": [
    {
    "Name": "{Website name}",
    "Directory": "/path_to_creatio_conf_directory/",
    "ContentWorkerArguments": {
    "key": "ContentPath",
    "value": "/path_to_creatio_conf_directory/content"
    }
    }
    ]
    }

4. Download the required Docker images​

Take this step only if you deploy the bundling service using the private Creatio image repository.

To download the required Docker images:

  1. Go to the directory that includes the configuration files of the bundling service, for example, "/opt/services."
  2. Run the docker-compose pull command.

5. Launch the bundling service elements​

  1. Go to the directory that includes the configuration files of the bundling service.
  2. Run the docker-compose up -d command to launch the bundling service elements.
  3. Run the docker ps command to view the names of the bundling service containers.
  4. Run the docker logs {Container} command to make sure the bundling service elements are launched successfully and view the logs. {Container} is the name of the Docker container you received in the previous step.

6. Make sure the bundling service is deployed successfully​

  1. Make sure the bundling service is set up correctly.

    1. Run the docker ps command and make sure the content-service and content-watcher containers have the "Up" status.
    2. Make sure the ContentPath variable in the ".env" file includes the path to the "/conf" directory of the Creatio instance.
    3. Make sure the ContentServiceUrl setting in the "appsettings.json" file includes the address and port where ContentService is launched.
    4. Make sure the Directory and ContentPath settings in the "appsettings.json" file include the paths to the "/conf" and "/conf/content" directories in the container.
  2. Make sure the bundling service is ready to accept requests to generate bundled files in one of the following ways:

    • Send a GET request to the {Server IP}:{Bundling service port} URL, for example, "1.2.3.4:5001."
    • Enter the {Server IP}:{Bundling service port} URL in the browser address bar.

    Where:

    • {Server IP} is the IP address of the server that includes the installed service.
    • {Bundling service port} is the port where ContentService is launched. By default, 5001.

    If the bundling service is ready to accept requests to generate bundled files, you receive the "Service is running. Go to /start page to use web interface" response.

  3. Make sure the static content of the Creatio instance is bundled correctly.

    1. Log in to Creatio.

    2. Save an arbitrary "Client module" type schema in the Configuration section, even without any changes.

    3. Run the docker logs {Container} command for the content-service container and verify the logs include the following record to make sure the bundling service starts to generate bundled files.

      INFO|ContentService.Web.API.ContentProcessingRequestHandler|Content processing (/process-content) is running for path /app/content/content...
    4. Run the docker logs {Container} command for the content-service container and verify the logs include the following record to make sure the process that generates bundled files is completed.

      INFO|ContentService.Web.API.ContentProcessingRequestHandler|Content processing (/process-content) finished in 12345ms for path /app/content/content
    5. Verify that the Network tab in browser debugging tools includes the "/conf/content/bundles/" requests whose *.js files have the "_bundle" prefix, for example, "/conf/content/bundles/_bundle_123.js," to make sure Creatio loads bundled files instead of static files.


See also​

Packages file content basics

ContentService service

ContentWatcher utility

Static content bundling service

Deploy the Creatio .NET application server on Linux (user documentation)


Resources​

Official vendor documentation (Docker)