Sha256: 0828092fe553523553bf3df6c6ff9bb6a82469137ca4356241a6514ca549357a
Contents?: true
Size: 923 Bytes
Versions: 3
Compression:
Stored size: 923 Bytes
Contents
module Rack class MogileFS class Endpoint # Adds support for expires headers. You can specify a number or a proc # that will recieve (path, ext, mime) as arguements. You should return # the number of seconds to cache. module Caching def initialize(*) super @options[:expires] ||= false end def headers(file) super.merge( cache_control_header(file) ) end private def cache_control_header(file) if @options[:expires] { "Cache-Control" => "max-age=#{max_age(file)}, public" } else {} end end def max_age(file) if @options[:expires].respond_to?(:call) @options[:expires].call(file.path, file.extname, file.content_type) else @options[:expires] end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rack-mogilefs-0.3.2 | lib/rack/mogilefs/endpoint/caching.rb |
rack-mogilefs-0.3.1 | lib/rack/mogilefs/endpoint/caching.rb |
rack-mogilefs-0.3.0 | lib/rack/mogilefs/endpoint/caching.rb |