From: Eric Wong Date: Sun, 5 Apr 2020 01:28:49 +0000 (+0000) Subject: wwwstatic: set "Vary: Accept-Encoding" in static gzip response X-Git-Tag: v1.4.0~24 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=6ebcec3add4d6aeff6e3b3eb019a404528c079ec wwwstatic: set "Vary: Accept-Encoding" in static gzip response We don't want to confuse intermediate caches into serving gzipped content to any clients which can't handle it. It probably doesn't matter in practice, though, since every HTTP client seems to handle "Content-Encoding: gzip" regardless of whether it was requested or not, though I could expect some nc/socat/telnet/s_client users being annoyed. This also matches the behavior of Plack::Middleware::Deflater and other deflater implementations. --- diff --git a/lib/PublicInbox/WwwStatic.pm b/lib/PublicInbox/WwwStatic.pm index 0c534b46..3c933156 100644 --- a/lib/PublicInbox/WwwStatic.pm +++ b/lib/PublicInbox/WwwStatic.pm @@ -117,7 +117,9 @@ sub try_gzip_static ($$$$) { return unless -f $gz && (stat(_))[9] == $mtime; my $res = response($env, $h, $gz, $type); return if ($res->[0] > 300 || $res->[0] < 200); - push @{$res->[1]}, qw(Cache-Control no-transform Content-Encoding gzip); + push @{$res->[1]}, qw(Cache-Control no-transform + Content-Encoding gzip + Vary Accept-Encoding); $res; }