/middleman-keycdn

An extension for middleman which allows you to invalidate KeyCDN cache

Primary LanguageRubyMIT LicenseMIT

Middleman KeyCDN Build Status Dependency Status Code Climate

A deploying tool for middleman which invalidates a KeyCDN cache.

Based almost entirely on middleman-cloudfront and used together with middleman-s3_sync (though you can use whatever deployment method & KeyCDN source you want)

Some of its features are:

  • KeyCDN cache invalidation — either purge the whole cache or just updated selected URLs;
  • Ability to call it from command line and after middleman build;
  • Ability to filter files which are going to be invalidated by regex;

Usage

Installation

Add this to Gemfile:

gem 'middleman-keycdn'

Then run:

bundle install

Configuration

Edit config.rb and add:

activate :keycdn do |cdn|
  cdn.api_key = ENV['KEYCDN_API_KEY']
  cdn.zone_id = ENV['KEYCDN_ZONE_ID']
  cdn.base_url = ENV['KEYCDN_BASE_URL']
  cdn.purge_all = true
  cdn.filter = /.html$/i  # default is /.*/
  cdn.after_build = true  # default is false
end```

## Running

If you set `after_build` to `true` cache would be automatically invalidated after build:  
```bash
bundle exec middleman build

Otherwise you should run it through commandline interface like so:

bundle exec middleman invalidate