# Implement full purge of Fastly CDN cache.  Invoke using:
#   heroku run rake fastly:purge --app NAME_OF_APPLICATION
# Run this if code changes will cause a change in badge level, since otherwise
# the old badge levels will keep being displayed until the cache times out.
# See: https://robots.thoughtbot.com/
# a-guide-to-caching-your-rails-application-with-fastly
namespace :fastly do
  desc 'Purge Fastly cache (takes about 5s)'
  task :purge do
    puts 'Starting full purge of Fastly cache (typically takes about 5s)'
    require Rails.root.join('config/initializers/fastly')
    FastlyRails.client.get_service(ENV.fetch('FASTLY_SERVICE_ID')).purge_all
    puts 'Cache purged'
  end
end

Add new "rake fastly:purge" command for purging Fastly cache
Add new "rake fastly:purge" command for purging Fastly cache

  This is useful when making changes to the code that cause
  sudden changes in the displayed badge level.

  This isn't tested yet, so there may be further changes to come.

Signed-off-by: David A. Wheeler <9ae72d22d8b894b865a7a496af4fab6320e6abb2@dwheeler.com>
