module Sprockets::Server
def headers(env, asset, length)
def headers(env, asset, length) Hash.new.tap do |headers| # Set content type and length headers headers["Content-Type"] = asset.content_type headers["Content-Length"] = length.to_s # Set caching headers headers["Cache-Control"] = "public" headers["Last-Modified"] = asset.mtime.httpdate headers["ETag"] = etag(asset) # If the request url contains a fingerprint, set a long # expires on the response if path_fingerprint(env["PATH_INFO"]) headers["Cache-Control"] << ", max-age=31536000" # Otherwise set `must-revalidate` since the asset could be modified. else headers["Cache-Control"] << ", must-revalidate" end end end