Sha256: 2e42ed559ac8c6463872b0c3304da764b5895c7c11e57655a7a7bd3e04be5d21
Contents?: true
Size: 617 Bytes
Versions: 7
Compression:
Stored size: 617 Bytes
Contents
module Spontaneous::Rack class CacheableFile < ::Rack::File include HTTP TEN_YEARS = 10*365*24*3600 MAX_AGE = "max-age=#{TEN_YEARS}, public".freeze def initialize(file_root) super(file_root, 'public') end def call(env) status, headers, body = super [status, caching_headers(headers), body] end # Send a far future Expires header and make sure that # the cache control is public def caching_headers(headers) headers.merge({ HTTP_CACHE_CONTROL => MAX_AGE, HTTP_EXPIRES => (Time.now + TEN_YEARS).httpdate }) end end end
Version data entries
7 entries across 7 versions & 1 rubygems