]> Sergey Matveev's repositories - public-inbox.git/commitdiff
wwwstatic: set "Vary: Accept-Encoding" in static gzip response
authorEric Wong <e@yhbt.net>
Sun, 5 Apr 2020 01:28:49 +0000 (01:28 +0000)
committerEric Wong <e@yhbt.net>
Sun, 5 Apr 2020 07:25:07 +0000 (07:25 +0000)
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.

lib/PublicInbox/WwwStatic.pm

index 0c534b46f0d546cdfd28c35138a3140664acf647..3c933156405bedb92db5afee4a3beed6a29506bc 100644 (file)
@@ -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;
 }