Sha256: 1b030084b24714e626a78072afdfd72d3ab677411dd5c196b3259647834d5095

Contents?: true

Size: 496 Bytes

Versions: 6

Compression:

Stored size: 496 Bytes

Contents

module Olelo
  module Middleware
    class StaticCache
      def initialize(app)
        @app = app
      end

      def call(env)
        # Add a cache-control header if asset is static with version string
        if env['PATH_INFO'].sub!(%r{^/static-\w+/}, '/static/')
          status, headers, body = @app.call(env)
          headers['Cache-Control'] = 'public, max-age=31536000'
          [status, headers, body]
        else
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
olelo-0.9.15 lib/olelo/middleware/static_cache.rb
olelo-0.9.14 lib/olelo/middleware/static_cache.rb
olelo-0.9.13 lib/olelo/middleware/static_cache.rb
olelo-0.9.12 lib/olelo/middleware/static_cache.rb
olelo-0.9.11 lib/olelo/middleware/static_cache.rb
olelo-0.9.10 lib/olelo/middleware/static_cache.rb