Skip to content

Instantly share code, notes, and snippets.

@Bluebie
Created February 21, 2009 12:19
Show Gist options
  • Save Bluebie/68025 to your computer and use it in GitHub Desktop.
Save Bluebie/68025 to your computer and use it in GitHub Desktop.
file_handler = Rack::File.new('.')
#...
proc { |env|
if !env['HTTP_IF_MODIFIED_SINCE'] || File.mtime(env['PATH_INFO'].sub(/\//, '')) > Time.rfc2822(env['HTTP_IF_MODIFIED_SINCE'])
r = file_handler.call(env)
r[1]['Expires'] = (Time.now + 60*60*24).httpdate if env['PATH_INFO'] =~ /(script|style)/
r
else
[304, {}, ['']]
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment