Kirby CDN Integration
This tutorial covers the CDN integration for the lightweight CMS Kirby and is based on their integration guide .
Create a Pull Zone or Push Zone before you start the Kirby integration.
Update the Kirby configuration file
site/config/config.php
. You can either use your own Zone Alias such ascdn.yourdomain.com
or the URL that KeyCDN provides for you (e.g.example-hexid.kxcdn.com
).return [ 'cdn' => true, 'cdn.domain' => 'https://cdn.yourdomain.com' ];
You can also disable the CDN altogether by setting the value to
false
.Modifying the URL component under
/site/plugins/cdn/index.php
will offload static assets to the CDN.Kirby::plugin('author/cdn', [ 'components' => [ 'url' => function ($kirby, $path, $options) { if (option('cdn', false) !== false && Str::startsWith($path, 'assets')) { return option('cdn.domain') . '/' . $path; } $original = $kirby->nativeComponent('url'); return $original($path, $options); }, ] ]);
With the code above, the
asset
folder is loaded from the CDN. The other paths remain the same and will not be loaded from the CDN. This can be adjusted to your needs.Verify that your assets are being delivered by KeyCDN.
Relevant links
- Kirby with KeyCDN's Image Processing.
- Kirby's cache busting automatically creates new versions of your assets.