Search code examples
amazon-s3amazon-cloudfrontcdnkentico

Does Kentico Auto-Prefix CDN Endpoint URLs to Media File Paths?


Is anyone here familiar with using Azure or Amazon CDN services with Kentico media libraries? I have a client running Kentico v10.0.21 with Amazon CloudFront CDN in the web.config. https://docs.kentico.com/k10/custom-development/working-with-physical-files-using-the-api/configuring-file-system-providers/configuring-amazon-s3#ConfiguringAmazonS3-ConfiguringKenticotouseAmazonCloudFrontCDN

They're running into an issue where Kentico doesn't prefix the CDN Endpoint URL to media file paths. Is there any native Kentico functionality for auto-prefixing the CDN path to Media Library selections if the web.config was set up to use a CDN? I could use a custom macro to read the value from the web.config and do something with that, but it seems strange that this wouldn't be a native feature of Kentico if it already enables using CDN endpoints.


Solution

  • I configured a clean Kentico 10 web site to store only media files on Azure storage, (https://docs.kentico.com/k10/custom-development/working-with-physical-files-using-the-api/configuring-file-system-providers/configuring-azure-storage#ConfiguringAzurestorage-ConfiguringKenticotostoreonlymediafilesonAzurestorage). Then, I configured Kentico to use a CDN, (https://docs.kentico.com/k10/running-kentico-on-microsoft-azure/configuring-azure-cdn#ConfiguringAzureCDN-ConfiguringKenticotouseaCDN). These were not Amazon storage or CDN resources because we do not have an active Amazon Web Services (AWS) account, but they should mimic Kentico's general approach to media files and external storage providers. After completing those custom configuration tasks, I applied hotfix 10.0.21 to ensure the Kentico instance was running the same hotfix as our client.

    I tested adding several media files. The media files always used an absolute URL for the direct path and relative URL for the permanent link. The direct path's absolute url always began with the CDN endpoint URL.

    I tested adding media files to pages using the Rich Text widget on the page tab. The img tag's src attribute always used the direct path and always began with the CDN endpoint URL.

    These tests confirm that Kentico already handles adding the CDN endpoint URL to the direct path of media files. If Kentico fails to prepend the CDN endpoint URL to the direct path of media files, then Kentico is not configured to use a CDN. If Kentico fails to prepend the cloud storage URL to the direct path of media files or uses relative URLs for the direct path of media files, then Kentico is not configured to store only media files on cloud storage.

    I suspect that our client was neither configured to store media files on cloud storage nor to use a CDN.