Skip to main content

Using a CDN for static assets

Performance Boosting

All of Deskpro's static application assets (such as Javascript and CSS) exist in the www/assets directory. If you wish to serve static application assets from a CDN for improved performance, you can follow this guide.

Sync assets to your CDN

As described above, all static assets exist in the www/assets directory. You need to sync this directory with your CDN.

For example:

  • On your server you might have: /deskpro/www/assets
    • An example file might be: /deskpro/www/assets/12345/web/images/dp-logo-48.png
  • Your CDN would therefore have:

You'll notice that within the assets directory, there is a sub-directory integer representing the version of Deskpro you are using (i.e. assets/12345). Every time you upgrade Deskpro, this number changes. It's important that you always sync the assets directory to your CDN whenever you upgrade Deskpro.

If your CDN provider lets you set caching settings, you can treat these assets as immutable -- i.e. you may set caching headers such that the cache never expires and never needs revalidating.

Deskpro Config

After you have a CDN configured and sync'd, you need to tell Deskpro to actually use your CDN.

Edit config/config.paths.php and append the following lines:

// Modify the URL here to point to your CDN
$cdn_base_url = '';

$PATHS_CONFIG['asset_paths'] = [
    'legacy_web'    => ['type' => 'url', 'value' => $cdn_base_url.'assets/%DP_ACTIVE_BUILD%/web'],
    'vendor_assets' => ['type' => 'url', 'value' => $cdn_base_url.'assets/%DP_ACTIVE_BUILD%/pub/node_modules'],
    'app_assets'    => ['type' => 'url', 'value' => $cdn_base_url.'assets/%DP_ACTIVE_BUILD%/pub/build'],
    'assets_root'   => ['type' => 'url', 'value' => $cdn_base_url.'assets/%DP_ACTIVE_BUILD%'],
    'appsrc_assets' => ['type' => 'url', 'value' => $cdn_base_url.'assets/%DP_ACTIVE_BUILD%/pub/src'],
Authors list

First published: 23/07/2018

Last updated: Jul 23, 2018 by Christopher Nadeau