frankfurter/lib/no_store_on_error.rb
BadMark d0a43e357a
Some checks failed
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / publish (push) Has been cancelled
CI/CD Pipeline / release (push) Has been cancelled
up
2026-05-21 01:38:14 -06:00

16 lines
487 B
Ruby

# frozen_string_literal: true
# Rack middleware that prevents CDNs and caches from holding onto error
# responses. Without this, an error inheriting the success path's
# `Cache-Control: public, max-age=86400` could be pinned at the edge for a day.
class NoStoreOnError
def initialize(app)
@app = app
end
def call(env)
status, headers, body = @app.call(env)
headers = headers.merge("cache-control" => "no-store") if status >= 400
[status, headers, body]
end
end