diff --git a/packages/ruby/server/lib/server/etag.rb b/packages/ruby/server/lib/server/etag.rb index cd731b3..5767fae 100644 --- a/packages/ruby/server/lib/server/etag.rb +++ b/packages/ruby/server/lib/server/etag.rb @@ -1,15 +1,19 @@ # frozen_string_literal: true class Server::ETag < Rack::ETag + ETAGS = {} + def initialize(app) @app = app end def call(env) - status, headers, body = super(env) - if env["HTTP_IF_NONE_MATCH"] == headers["etag"] + headers = ETAGS[env["REQUEST_PATH"]] || {} + if headers["etag"] && headers["etag"] == env["HTTP_IF_NONE_MATCH"] [304, headers, [""]] else + status, headers, body = super(env) + ETAGS[env["REQUEST_PATH"]] = headers [status, headers, body] end end