Skip to content

Commit 91ade09

Browse files
committed
docs(plugin-hono-server, hono): say which 304 answers carry Vary, and that the hosted door leaves compression to the platform
Claude-Session: https://claude.ai/code/session_016WV4cxHwXNcGcAHNerZsom Co-authored-by: Claude <noreply@anthropic.com>
1 parent cec1282 commit 91ade09

6 files changed

Lines changed: 74 additions & 9 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/plugin-hono-server': patch
3+
'@objectstack/hono': patch
4+
---
5+
6+
docs(plugin-hono-server, hono): say which `304` answers carry `Vary: Accept-Encoding`, and that the hosted door leaves compression to the platform or CDN (#32565, #32536)
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
No runtime behaviour changes; the READMEs both packages ship now say what the server does.
12+
13+
- `@objectstack/plugin-hono-server`: the README said every `304` for a compressible response carries `Vary: Accept-Encoding`. The server decides from the answer it sends, not from the `200` the `304` stands for, so a `304` carries that `Vary` only when it carries a compressible `Content-Type` of its own. A dispatcher answer written with `res.json()` does; a bare `304` with only `ETag` and `Cache-Control` (the Console's static files answer one) does not. A cache refreshing a stored answer from a `304` keeps the stored `Vary`, so no cached answer is wrong. A new test pins both shapes.
14+
- `@objectstack/hono`: `createHonoApp`, the hosted door for edge runtimes, does not compress responses and sends no `Vary: Accept-Encoding`. Compression there is the job of the platform or CDN in front of the app, as ruled on #32155 (ruling Y′). The README now says so, and asks operators to check that their host compresses and keeps the `ETag` unchanged.

‎content/docs/deployment/production-readiness.mdx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,22 @@ those responses are **per-caller**, and the rules below are what keep that safe.
241241
set, every caller is served every object, including objects they may not
242242
read, which the mask otherwise answers as objects that do not exist.
243243

244+
## Response compression on each door
245+
246+
Who compresses a response depends on the door that serves it:
247+
248+
| Door | Who compresses |
249+
| :--- | :--- |
250+
| Self-hosted server: `@objectstack/plugin-hono-server`, what `os dev` and `os start` run | **The server**, by default: brotli or gzip for compressible responses of 1 KB or more. See [Response Compression](/docs/protocol/kernel/http-protocol#response-compression). |
251+
| Hosted door: `createHonoApp` from `@objectstack/hono` on Cloudflare Workers, Deno Deploy, Bun or Vercel Edge | **The platform or CDN in front of it.** The application does not compress there: it sends no `Content-Encoding` and no `Vary: Accept-Encoding`. |
252+
253+
On the hosted door, check that the platform compresses JSON, JavaScript and CSS
254+
responses, and turn it on there if it does not (a runtime you serve yourself
255+
may not compress at all: put a proxy or CDN in front of it), rather than adding
256+
compression to the app. Either way, keep the `ETag` unchanged when a layer
257+
compresses: saves send it back as `If-Match` and the server compares it
258+
strongly, so a layer that weakens it to `W/` makes those saves fail.
259+
244260
## What's NOT in the runtime (yet)
245261

246262
- **OTel context propagation.** We export `parseTraceparent` /

‎content/docs/protocol/kernel/http-protocol.mdx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,9 +1185,17 @@ Vary: Accept-Encoding
11851185
- Responses that already carry a `Content-Encoding`, `206 Partial Content`,
11861186
`HEAD`, and responses marked `Cache-Control: no-transform` are sent unchanged.
11871187
- Every response the server could encode carries `Vary: Accept-Encoding`. So do
1188-
the `HEAD`, `206` and `304` answers for such a response.
1188+
the `HEAD` and `206` answers for such a response.
1189+
- A `304 Not Modified` is never encoded. It carries `Vary: Accept-Encoding` only
1190+
when it carries a compressible `Content-Type` of its own, because the server
1191+
judges the answer it sends, not the `200` the `304` stands for. A bare `304`
1192+
has no `Vary`, and a cache refreshing its stored copy from it keeps the
1193+
stored `Vary`.
11891194
- The `ETag` is the same on encoded and unencoded answers. A save sends it back
11901195
as `If-Match`, and the server compares it strongly.
1196+
- The hosted door (`createHonoApp` from `@objectstack/hono`, on edge runtimes)
1197+
does not compress: the platform or CDN in front of it does. See
1198+
[Production readiness](/docs/deployment/production-readiness#response-compression-on-each-door).
11911199

11921200
## Rate Limiting
11931201

‎packages/adapters/hono/README.md‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,24 @@ app.use('/api/*', objectStackMiddleware(kernel));
7979
- Drivers differ by runtime: use [`@objectstack/driver-sql`](../../drivers/driver-sql) on Node. (Edge/multi-tenant turso driver ships in ObjectOS Cloud.)
8080
- Persist no long-lived state in module scope beyond the `kernel` instance.
8181

82+
## Response compression
83+
84+
`createHonoApp` does not compress responses. It sends no `Content-Encoding` and adds no
85+
`Vary: Accept-Encoding`. On this door, compression is the job of the platform or CDN in
86+
front of the app, and the application does not compress there. The edge runtimes this
87+
adapter targets do not all offer `node:zlib`, and the edge already does this work.
88+
89+
- Check that your host compresses JSON, JavaScript and CSS responses. If it does not,
90+
turn it on there, not in the app. A runtime you serve yourself may not compress at
91+
all; put a proxy or CDN in front of it.
92+
- Keep the `ETag` unchanged when the host compresses. Saves send it back as `If-Match`
93+
and the server compares it strongly, so a host that rewrites it to a weak `W/` tag
94+
makes those saves fail their precondition.
95+
96+
The self-hosted server, [`@objectstack/plugin-hono-server`](../../plugins/plugin-hono-server)
97+
(what `os dev` and `os start` run), does compress responses itself; its README says
98+
which ones.
99+
82100
## When to use
83101

84102
- ✅ Edge, serverless, and multi-runtime deployments.

‎packages/plugins/plugin-hono-server/README.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,12 @@ whichever route serves them. These responses are never encoded:
174174
- **Responses marked `Cache-Control: no-transform`.**
175175

176176
Every response the server could encode carries `Vary: Accept-Encoding`, whatever the
177-
client sent. So do the `HEAD`, `206` and `304` answers for such a response, although
178-
they are never encoded themselves. The `ETag` is passed through unchanged. Saves send it back as `If-Match`
177+
client sent. So do the `HEAD` and `206` answers for such a response, although they are
178+
never encoded themselves. A `304 Not Modified` is never encoded either, and it carries
179+
`Vary: Accept-Encoding` only when it carries a compressible `Content-Type` of its own:
180+
the server judges the answer it sends, not the `200` the `304` stands for. A bare `304`
181+
(the Console's static files answer one) has no `Vary`; a cache refreshing its stored
182+
copy from it keeps the stored `Vary`. The `ETag` is passed through unchanged. Saves send it back as `If-Match`
179183
and the server compares it strongly, so a weakened `W/` tag would fail those saves.
180184

181185
A reverse proxy or CDN in front of the server sees `Content-Encoding` and does not

‎packages/plugins/plugin-hono-server/src/response-compression.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@
3737
*
3838
* `Vary: Accept-Encoding` goes on every response this could encode, whatever
3939
* the request accepted and whatever the body's size, so a shared cache never
40-
* hands one client's encoding to another. It also goes on the `HEAD`, `206`
41-
* and `304` answers for such a response, which are never encoded themselves:
42-
* a `HEAD` carries the header fields its `GET` would, and a cache refreshes a
43-
* stored answer's headers from a `304`. The `ETag` is passed through
40+
* hands one client's encoding to another. It also goes on the `HEAD` and `206`
41+
* answers for such a response, which are never encoded themselves: a `HEAD`
42+
* carries the header fields its `GET` would. The rule reads the answer it is
43+
* handed, never the route's `200`, so a `304` carries it only when the `304`
44+
* itself carries a compressible `Content-Type` (the dispatcher's `res.json()`
45+
* answers do; the Console's bare stable-file `304` does not). A cache that
46+
* refreshes a stored answer from a `304` keeps the stored `Vary`, so a `304`
47+
* without one loses nothing. The `ETag` is passed through
4448
* unchanged: the metadata and record doors compare an `If-Match` token against
4549
* it strongly, so rewriting it to a weak `W/` form on encoded answers would make
4650
* every save that pins the version it just read fail its precondition.
@@ -219,8 +223,9 @@ export async function compressResponse(
219223
if (vary !== '*' && !(vary && VARY_ACCEPT_ENCODING.test(vary))) {
220224
c.header('Vary', vary ? `${vary}, Accept-Encoding` : 'Accept-Encoding');
221225
}
222-
// A `HEAD`, a partial answer and a revalidation carry the `Vary` of the
223-
// full answer they stand for, and are never encoded themselves.
226+
// A `HEAD`, a partial answer and a revalidation are never encoded
227+
// themselves. A `304` reaches this line only when it carries a
228+
// compressible `Content-Type` of its own: a bare `304` gets no `Vary`.
224229
if (c.req.method === 'HEAD' || c.res.status === 206 || c.res.status === 304) return;
225230

226231
const length = declaredLength(c.res.headers);

0 commit comments

Comments
 (0)