The framework's response cache: the handler skipped and a stored answer replayed, keyed by a path segment and by request header, and kept for 30 seconds.
Comparable across stores rather than across frameworks. Several frameworks ship no response cache and run a package chosen for them, so a ranking that carried these rows would be ranking the package.
| test | heft | request | base | what differs from the base |
|---|---|---|---|---|
| cache.large | 3 | GET /cache/large/{draw.key} | json.large | the handler skipped and a stored response replayed |
| cache.medium | 1 | GET /cache/medium/{draw.key} | json.medium | the handler skipped and a stored response replayed |
| cache.small | 1 | GET /cache/small/{draw.key} | json.small | the handler skipped and a stored response replayed |
| cache.vary_one | 1 | GET /cache/vary/one/{draw.key} | cache.small | the stored response keyed by request headers as well as by path |
| cache.vary_many | 1 | GET /cache/vary/many/{draw.key} | cache.vary_one | the stored response keyed by request headers as well as by path |
The handler skipped and a stored answer written back, under one of four keys the path names. Read against json.large, the difference is the store answering instead of the framework, which is why this row asserts the serial repeated rather than changed.
GET /cache/large/{draw.key}No body.
HTTP 200
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 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 = "/cache/large/{draw.key}";
export default performanceTest({
id: { family: "cache", name: "large" },
path,
base: "json.large",
varies: "response_cache",
heft: 3,
about:
"The handler skipped and a stored answer written back, under one of four " +
"keys the path names. Read against json.large, the difference is the store " +
"answering instead of the framework, which is why this row asserts the " +
"serial repeated rather than changed.",
request: (c) => c.get(`/cache/large/${c.draw.key()}`).okWith(items.large).replayed(),
});
The handler skipped and a stored answer written back, under one of four keys the path names. Read against json.medium, the difference is the store answering instead of the framework, which is why this row asserts the serial repeated rather than changed.
GET /cache/medium/{draw.key}No body.
HTTP 200
payload items.medium
{"size":"medium","count":89,"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":"kitc
… 7,953 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 = "/cache/medium/{draw.key}";
export default performanceTest({
id: { family: "cache", name: "medium" },
path,
base: "json.medium",
varies: "response_cache",
heft: 1,
about:
"The handler skipped and a stored answer written back, under one of four " +
"keys the path names. Read against json.medium, the difference is the store " +
"answering instead of the framework, which is why this row asserts the " +
"serial repeated rather than changed.",
request: (c) => c.get(`/cache/medium/${c.draw.key()}`).okWith(items.medium).replayed(),
});
The handler skipped and a stored answer written back, under one of four keys the path names. Read against json.small, the difference is the store answering instead of the framework, which is why this row asserts the serial repeated rather than changed.
GET /cache/small/{draw.key}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 = "/cache/small/{draw.key}";
export default performanceTest({
id: { family: "cache", name: "small" },
path,
base: "json.small",
varies: "response_cache",
heft: 1,
about:
"The handler skipped and a stored answer written back, under one of four " +
"keys the path names. Read against json.small, the difference is the store " +
"answering instead of the framework, which is why this row asserts the " +
"serial repeated rather than changed.",
request: (c) => c.get(`/cache/small/${c.draw.key()}`).okWith(items.small).replayed(),
});
The stored answer keyed by a request header as well as by the path. One header with two values, picked per instance, so a store that ignores the vary header holds four entries where the plan sent eight keys.
GET /cache/vary/one/{draw.key}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 = "/cache/vary/one/{draw.key}";
/** Two tenants, so a store that ignores the header holds one entry where two keys were sent. */
const tenants = ["alpha", "beta"];
export default performanceTest({
id: { family: "cache", name: "vary_one" },
path,
base: "cache.small",
varies: "cache_key",
heft: 1,
about:
"The stored answer keyed by a request header as well as by the path. One " +
"header with two values, picked per instance, so a store that ignores the " +
"vary header holds four entries where the plan sent eight keys.",
request: (c) =>
c
.get(`/cache/vary/one/${c.draw.key()}`)
.header("x-rb-tenant", c.draw.choice(tenants))
.okWith(items.small)
.replayed(),
});
The same thing keyed on three headers instead of one. Read against cache.vary_one, the difference is thirty-two distinct keys where there were eight, which is what a store has to be sized against rather than what it costs to read.
GET /cache/vary/many/{draw.key}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 = "/cache/vary/many/{draw.key}";
/** Two values of each header, so a store that ignores one holds half the entries it was sent. */
const channels = ["web", "app"];
const regions = ["eu", "us"];
const tenants = ["alpha", "beta"];
export default performanceTest({
id: { family: "cache", name: "vary_many" },
path,
base: "cache.vary_one",
varies: "cache_key",
heft: 1,
about:
"The same thing keyed on three headers instead of one. Read against " +
"cache.vary_one, the difference is thirty-two distinct keys where there were " +
"eight, which is what a store has to be sized against rather than what it " +
"costs to read.",
request: (c) =>
c
.get(`/cache/vary/many/${c.draw.key()}`)
.header("x-rb-channel", c.draw.choice(channels))
.header("x-rb-region", c.draw.choice(regions))
.header("x-rb-tenant", c.draw.choice(tenants))
.okWith(items.small)
.replayed(),
});