Integrated CDN

Last Updated: Sep 11, 2023
documentation for the dotCMS Content Management System

dotCMS Cloud includes an integrated CDN application, introduced in version 5.3.8.

The integrated CDN plugin allows information to be invalidated in these ways:

  • Admin Tool: Assets can be invalidated as needed using the CDN admin screen.
  • Workflow Actionlet: The integrated CDN also provides a workflow actionlet that can be added to workflow steps that will automatically invalidate a customer’s content when it is published/unpublished. Customers will need to be set up and apply the workflow action to the specific workflow steps to work.

This document provides an overview of the different different ways to utilize the CDN Application.

Adding assets to the CDN

To add assets to your CDN use $dotcdn.cdnify() in your VTL code to reference the CDN url of an asset using an absolute path. The example below will associate the JPG with the CDN. <img src="$dotcdn.cdnify('/dA/0ea0d2e93b/Eagle-Deception-Pass-lg.jpg')"> Also use cache-busting URLs using dotCMS inodes or other such mechanisms and other CDN strategies outlined in this documentation.

Purge

Purging your CDN is a very important step to keep the information in the CDN up to date. A purge can be done from three places: the dotCDN page, the Workflow actionlet and outside of dotCMS using the endpoint.

Manual Purge

On the Flush cache tab of the CDN page under Dev tools there are 2 optional parameters for manually flush the CDN.

  • You can enter specific CDN URL paths to be removed including whole folders using the * wildcard character.
  • The second option is to purge the entire cache for whichever site you are currently on.
  • If your page URL says demo.dotcms.com and you have a CDN specifically for demo, that will be the cache you are purging. Other caches under the same host would not be affected.
  • If you do not have a specific CDN for the site you are currently on but you do have a system host CDN Purge all will purge the system host CDN.

Workflow Purge

You can also purge your CDN using workflow actions so that the necessary information is purged from your CDN every time that step is executed. Typically you will want the purge on the Publish and Unpublish steps. To add the workflow purge follow the following steps

  1. Choose a workflow on the workflow page
  2. Chose the step you would like to add the purge to
  3. Add workflow subaction “dotCDN Purge” to that step
  4. Click on the dotCDN Purge and choose what you would like to purge.

There are two optional parameters for purging the cache in the workflow dotCDN Purge, by default Purge Contentlet is set as true:

  • If you set Purge Contentlet to true then it will purge the following 5 paths for the content that the workflow step is acting on, in addition to all the pages that content is used on.
    {cdnhostname}/{pathOfContentlet}
    {cdnhostname}/dA/{identifier}/*
    {cdnhostname}/dA/{inode}/*
    {cdnhostname}/dA/{shortyidentifier}/*
    {cdnhostname}/dA/{inode}/* 
    
  • URL Purge will purge every URL in this list everytime that step is reached. This is typically used for theme files.

Purge via Endpoint

The final way to purge it to do it outside of dotCMS using the endpoint. This purge can be done with curl or postman. The call would be:

DELETE http:locahost:8082/api/v1/dotcdn

With the body of the call being:

    {
    "urls":[],
    "invalidateAll":true,
    "hostId":"{HOST_IDENTIFIER}"
    }

In the url square brackets you would put the URLs to purge comma separated. In addition, you would replace {HOST_IDENTIFIER} with the identifier of the CDN host where the URLs you are purging are.

Statistics

dotCMS produces graphs visualising multiple useful statistics about your CDN. These statistics can be accessed in two ways; in dotCMS and externally using the Endpoint.

Statistics in dotCMS

These statistics live under the developers menu on the overview tab of the CDN page. The metrics shown are Bandwidth Used, Requests Served, Cache Hit Rate. Also graphs are shown for both the Requests Served and Bandwidth Served over time.

Statistics via Endpoint

The same statistics seen in dotCMS can be retrieved outside of dotCMS by calling the following using curl or postman.

GET http:localhost:8082/api/v1/dotcdn/stats?hostId={HOST_IDENTIFIER}
&dateTo=2021-04-15&dateFrom=2021-04-13

When using the endpoint to get statistics replace the {HOST_IDENTIFIER} with the ID of the host CDN you are targeting. In addition replace the dates with the dates you would like to see the data for.

On this page

×

We Dig Feedback

Selected excerpt:

×