Sha256: ebc8790a2b5d187d8c934aff3a4beb9dab896c71c3230b009b392fdaff7fc5d6
Contents?: true
Size: 928 Bytes
Versions: 19
Compression:
Stored size: 928 Bytes
Contents
module Shipit class StripCacheControl < Faraday::Middleware def call(request_env) @app.call(request_env).on_complete do |response_env| if headers = response_env[:response_headers] headers.delete('last-modified') directives = parse(headers['cache-control'].to_s) directives.delete('max-age') directives.delete('s-maxage') headers['cache-control'] = dump(directives) end end end private def dump(directives) directives.map do |k, v| if v == true k else "#{k}=#{v}" end end.join(', ') end def parse(header) directives = {} header.delete(' ').split(',').each do |part| next if part.empty? name, value = part.split('=', 2) directives[name.downcase] = (value || true) unless name.empty? end directives end end end
Version data entries
19 entries across 19 versions & 1 rubygems