perf(compression): send no Vary on a body under the threshold
A buffered body under the threshold is sent identity whatever the client accepts, so Accept-Encoding played no part in it and RFC 9110 asks for no Vary. A cache that stores it for everyone is right to: every client accepts identity. Responses that are encoded, or that are identity for a request-side reason (identity client, HEAD), and every 304 keep Vary, as does every compressible edge response, since Cloudflare encodes there. Deno pays about 10% of a small request for the header, Bun about 3%. The size is also measured with Buffer.byteLength instead of allocating the bytes, which are now built only when the body is encoded. Measured on the Mac, hello with compression on against compression off: Deno -17% -> -2%, Bun -7% -> -3%. Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
4 files changed
+18
-9
No files matched your search
@@ -135,7 +135,7 @@ for (const adapter of ['node', 'fetch'] as const) {
|
||||
});
|
||||
|
||||
it.each([
|
||||
['/c/small', 'T7 under threshold', true],
|
||||
['/c/small', 'T7 under threshold', false],
|
||||
['/c/png', 'T8 image/png', false],
|
||||
['/c/notype', 'T8 missing content-type', false],
|
||||
['/c/range', 'T8 content-range', false],
|
||||
|
||||
Vendored
+1
-1
@@ -60,7 +60,7 @@ async function negotiation(port: number): Promise<void> {
|
||||
/** T7, T8, T11, T15: skips, and the 304 shape. */
|
||||
async function skips(port: number): Promise<void> {
|
||||
for (const [path, vary] of [
|
||||
['/c/small', true],
|
||||
['/c/small', false],
|
||||
['/c/png', false],
|
||||
['/c/notype', false],
|
||||
['/c/range', false],
|
||||
|
||||
Reference in new issue
Block a user