Sha256: 2997829b43c438315fc3044af57b4ebe1d32c8463906642e9d45d5ac9ff16d17

Contents?: true

Size: 575 Bytes

Versions: 13

Compression:

Stored size: 575 Bytes

Contents

require 'rack/cache'

module Locomotive
  module Middlewares
    class Cache

      def initialize(app, opts = {}, &block)
        url_format  = Locomotive::Dragonfly.app.configuration[:url_format]
        base_format = url_format.split('/:').first rescue '/images/dynamic'

        @app      = app
        @regexp   = %r{^#{base_format}/}
        @context  = ::Rack::Cache.new(app, opts, &block)
      end

      def call(env)
        if env['PATH_INFO'] =~ @regexp
          @context.call(env)
        else
          @app.call(env)
        end
      end

    end

  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
locomotive_cms-2.4.1 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.4.0 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.3.1 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.3.0 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.2.3 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.2.2 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.2.1 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.2.0 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.1.4 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.1.3 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.1.2 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.1.1 lib/locomotive/middlewares/cache.rb
locomotive_cms-2.1.0 lib/locomotive/middlewares/cache.rb