Outbound gzip: the wiring declining, the wiring working, and the small-body threshold.
Comparable across every framework. The identity rows carry the middleware installed and refusing, so subtracting them from the gzip rows leaves the compression itself.
| test | heft | request | base | what differs from the base |
|---|---|---|---|---|
| compressed.identity_large | 4 | GET /compressed/large | json.large | the compression middleware installed and declining |
| compressed.gzip_large | 5 | GET /compressed/large | compressed.identity_large | the compression middleware actually compressing |
| compressed.identity_small | 1 | GET /compressed/small | json.small | the compression middleware installed and declining |
| compressed.gzip_small | 2 | GET /compressed/small | compressed.identity_small | the compression middleware actually compressing |
The compression middleware installed and declining. The client asks for identity, so nothing is compressed and what this row carries is the cost of the wiring being in the path at all. It is what the gzip arm is subtracted from.
GET /compressed/large
No body.
HTTP 200
identitypayload items.large
{"size":"large","count":1425,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true},{"id":2,"name":"brass-hinge-5716","category":"garden","priceCents":17577,"inStock":true},{"id":3,"name":"linen-ring-6971","category":"kitchen","priceCents":5540,"inStock":true},{"id":4,"name":"copper-bolt-9217","category":"outdoor","priceCents":11562,"inStock":true},{"id":5,"name":"linen-lamp-8288","category":"office","priceCents":1413,"inStock":true},{"id":6,"name":"copper-pan-9308","category":"tools","priceCents":10795,"inStock":true},{"id":7,"name":"slate-seed-3051","category":"garden","priceCents":9667,"inStock":false},{"id":8,"name":"oak-lamp-8662","category":"kit
… 128,510 bytes totalCompared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { items } from "#payloads";
const path = "/compressed/large";
export default performanceTest({
id: { family: "compressed", name: "identity_large" },
path,
base: "json.large",
varies: "compression_wiring",
heft: 4,
about:
"The compression middleware installed and declining. The client asks for " +
"identity, so nothing is compressed and what this row carries is the cost " +
"of the wiring being in the path at all. It is what the gzip arm is " +
"subtracted from.",
request: (c) =>
c
.get(path)
.header("accept-encoding", "identity")
.header("cache-control", "no-cache")
.okWith(items.large, { compressed: false })
.fresh(),
});
The middleware compressing a body large enough to be worth it. Read against compressed.identity_large, the difference is the compression and nothing else, because both rows carry the same wiring.
GET /compressed/large
No body.
HTTP 200
gzippayload items.large
{"size":"large","count":1425,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true},{"id":2,"name":"brass-hinge-5716","category":"garden","priceCents":17577,"inStock":true},{"id":3,"name":"linen-ring-6971","category":"kitchen","priceCents":5540,"inStock":true},{"id":4,"name":"copper-bolt-9217","category":"outdoor","priceCents":11562,"inStock":true},{"id":5,"name":"linen-lamp-8288","category":"office","priceCents":1413,"inStock":true},{"id":6,"name":"copper-pan-9308","category":"tools","priceCents":10795,"inStock":true},{"id":7,"name":"slate-seed-3051","category":"garden","priceCents":9667,"inStock":false},{"id":8,"name":"oak-lamp-8662","category":"kit
… 128,510 bytes totalCompared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { items } from "#payloads";
const path = "/compressed/large";
export default performanceTest({
id: { family: "compressed", name: "gzip_large" },
path,
base: "compressed.identity_large",
varies: "compression",
heft: 5,
about:
"The middleware compressing a body large enough to be worth it. Read " +
"against compressed.identity_large, the difference is the compression and " +
"nothing else, because both rows carry the same wiring.",
request: (c) =>
c
.get(path)
.header("accept-encoding", "gzip")
.header("cache-control", "no-cache")
.okWith(items.large, { compressed: true })
.fresh(),
});
The compression middleware installed and declining. The client asks for identity, so nothing is compressed and what this row carries is the cost of the wiring being in the path at all. It is what the gzip arm is subtracted from.
GET /compressed/small
No body.
HTTP 200
identitypayload items.small
{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}]}Compared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { items } from "#payloads";
const path = "/compressed/small";
export default performanceTest({
id: { family: "compressed", name: "identity_small" },
path,
base: "json.small",
varies: "compression_wiring",
heft: 1,
about:
"The compression middleware installed and declining. The client asks for " +
"identity, so nothing is compressed and what this row carries is the cost " +
"of the wiring being in the path at all. It is what the gzip arm is " +
"subtracted from.",
request: (c) =>
c
.get(path)
.header("accept-encoding", "identity")
.header("cache-control", "no-cache")
.okWith(items.small, { compressed: false })
.fresh(),
});
The middleware actually asked to compress, on a body too small to benefit. Whether a framework bothers is the point, so this row does not assert that the answer came back compressed; it asserts the answer is right either way.
GET /compressed/small
No body.
HTTP 200
payload items.small
{"size":"small","count":1,"items":[{"id":1,"name":"slate-lamp-6647","category":"tools","priceCents":18928,"inStock":true}]}Compared as parsed JSON, so key order and how a number is written do not matter.
import { performanceTest } from "#kit";
import { items } from "#payloads";
const path = "/compressed/small";
export default performanceTest({
id: { family: "compressed", name: "gzip_small" },
path,
base: "compressed.identity_small",
varies: "compression",
heft: 2,
about:
"The middleware actually asked to compress, on a body too small to " +
"benefit. Whether a framework bothers is the point, so this row does not " +
"assert that the answer came back compressed; it asserts the answer is " +
"right either way.",
request: (c) =>
c
.get(path)
.header("accept-encoding", "gzip")
.header("cache-control", "no-cache")
.okWith(items.small)
.fresh(),
});