Kirby CDN integration

Introduction

Kirby is a lightweight CMS that doesn’t have any database and configurations, web content, template files and plugins are saved as files. All in all, it’s simple and very focused, and you should try your hands with it because:

  • It provides workflow with fast responses.
  • It’s a CMS with a handy panel control.
  • No database is required.

To speed up Kirby, try a CDN service. Below, you’ll find some tips and clues on how to integrate Kirby with content delivery network.

Before you start

  • Before you take any steps please back up your files and database.
  • In the following, we will integrate a CDN service using the CDN domain 12345.r.cdnsun.net. Please visit the Services/How-To section to obtain your CDN domain.
  • To integate a CDN service on https:// website you can use https://12345.r.cdnsun.net or you can use a custom CDN domain with SSL enabled.
  • If your website embeds custom fonts then please first enable CORS for them.
  • Before you take any steps please make sure that your CDN domain is ready-to-use here.

Create CDN Static service

Please refer to Creating a CDN Static service for more details.

Enable CDN in Kirby

  1. Download the Kirby CDN Plugin from its GitHub page. You can use the following git command:
    git clone https://github.com/getkirby-plugins/cdn-plugin.git            
    
    This will create a directory cdn-plugin and clone the Kirby CDN plugin git repository from GitHub to that directory.
  2. Create a directory site/plugins/cdn in your Kirby document root.
  3. Copy all files from the cdn-plugin directory to the site/plugins/cdn directory.
  4. Add your CDN domain to the Kirby configuration file site/config/config.php:
    c::set('cdn.assets',    'http://12345.r.cdnsun.net');
    c::set('cdn.content',   'http://12345.r.cdnsun.net');
    c::set('cdn.thumbs',    'http://12345.r.cdnsun.net');        
    
  5. That's all.

Notes

  • View HTML source code of your web pages to verify that you are using CDN, you should see source attribute of your images, CSS, JavaScript, etc. beginning with your CDN domain.
  • Don't see your CDN domain in source code of your web pages? If your website is using any cache plug-in/mechanism then you might want to clear/flush its cache.
  • Having troubles with custom fonts? Please refer to Using custom fonts with CDN - setting CORS for more details.
  • Still having troubles? Check your CDN URLs in our CDN content check or please refer to Debugging a CDN service for more hints.

Contact Us

  _  _    __   __   __   __  
 | \| ||  \ \\/ //  \ \\/ // 
 |  ' ||   \ ` //    \   //  
 | .  ||    | ||     / . \\  
 |_|\_||    |_||    /_//\_\\ 
 `-` -`     `-`'    `-`  --`