← tests

compressed

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.

testheftrequestbasewhat differs from the base
compressed.identity_large4GET /compressed/largejson.largethe compression middleware installed and declining
compressed.gzip_large5GET /compressed/largecompressed.identity_largethe compression middleware actually compressing
compressed.identity_small1GET /compressed/smalljson.smallthe compression middleware installed and declining
compressed.gzip_small2GET /compressed/smallcompressed.identity_smallthe compression middleware actually compressing

compressed.identity_large

heft 4

base json.largebase of compressed.gzip_large

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

GET /compressed/large
accept-encodingidentity
cache-controlno-cache

No body.

Expected response

HTTP 200
content-encodingis absent or identity
x-rb-serialis new, so the handler ran

payload 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 total

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/compressed/identity-large.ts
tests/compressed/identity-large.tsopen on GitHub →
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(),
});

compressed.gzip_large

heft 5

base compressed.identity_large

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

GET /compressed/large
accept-encodinggzip
cache-controlno-cache

No body.

Expected response

HTTP 200
content-encodingis gzip
x-rb-serialis new, so the handler ran

payload 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 total

Compared as parsed JSON, so key order and how a number is written do not matter.

Test source, tests/compressed/gzip-large.ts
tests/compressed/gzip-large.tsopen on GitHub →
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(),
});

compressed.identity_small

heft 1

base json.smallbase of compressed.gzip_small

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

GET /compressed/small
accept-encodingidentity
cache-controlno-cache

No body.

Expected response

HTTP 200
content-encodingis absent or identity
x-rb-serialis new, so the handler ran

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.

Test source, tests/compressed/identity-small.ts
tests/compressed/identity-small.tsopen on GitHub →
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(),
});

compressed.gzip_small

heft 2

base compressed.identity_small

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

GET /compressed/small
accept-encodinggzip
cache-controlno-cache

No body.

Expected response

HTTP 200
x-rb-serialis new, so the handler ran

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.

Test source, tests/compressed/gzip-small.ts
tests/compressed/gzip-small.tsopen on GitHub →
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(),
});