class Middleman::Extensions::CacheBuster
The Cache Buster extension
def initialize(app, options_hash = ::Middleman::EMPTY_HASH, &block)
def initialize(app, options_hash = ::Middleman::EMPTY_HASH, &block) super require 'set' @set_of_exts = Set.new(options.exts || app.config[:asset_extensions]) @set_of_sources = Set.new options.sources end
def manipulate_resource_list_container!(resource_list)
def manipulate_resource_list_container!(resource_list) resource_list.by_extensions(@set_of_sources).each do |r| next if Array(options.rewrite_ignore || []).any? do |i| ::Middleman::Util.path_match(i, "/#{r.destination_path}") end r.add_filter ::Middleman::InlineURLRewriter.new(:cache_buster, app, r, url_extensions: @set_of_exts, ignore: options.ignore, proc: method(:rewrite_url)) end end
def rewrite_url(asset_path, _dirpath, _request_path)
def rewrite_url(asset_path, _dirpath, _request_path) asset_path + '?' + Time.now.strftime('%s') end