Subject: | Plack::Middleware::Deflater doesn't set Vary header on 304 responses |
Date: | Wed, 20 Mar 2019 17:21:55 +1100 |
To: | bug-Plack-Middleware-Deflater [...] rt.cpan.org |
From: | Mark Nottingham <mnot [...] mnot.net> |
In Plack::Middleware::Deflater,
~~~
if (Plack::Util::status_with_no_entity_body($res->[0]) or
$h->exists('Cache-Control') && $h->get('Cache-Control') =~ /\bno-transform\b/) {
return;
}
my @vary = split /\s*,\s*/, ($h->get('Vary') || '');
push @vary, 'Accept-Encoding';
push @vary, 'User-Agent' if $self->vary_user_agent;
$h->set('Vary' => join(",", @vary));
~~~
This has the effect of only setting the Vary header if the response has an entity body; specifically, it omits Vary on 304 responses.
That is counter to HTTP's requirements; RFC7232 says:
Show quoted text
> The server generating a 304 response MUST generate any of the following header fields that would have been sent in a 200 (OK) response to the same request: Cache-Control, Content-Location, Date, ETag, Expires, and Vary.
--
Mark Nottingham https://www.mnot.net/