frankfurter/lib/no_store_on_error.rb

17 lines
487 B
Ruby
Raw Permalink Normal View History

2026-05-21 01:38:14 -06:00
# 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