You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d975131
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: AGENTS.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,7 @@ Never touch contents inside `<!-- automd -->` in README.md. They are auto genera
51
51
- Request narrowing (cookie stripping, authorization stripping, query narrowing) only applies to cacheable calls: non-GET/HEAD requests bypass the cache (`_shouldBypassCache`, composed with any caller `shouldBypassCache`) and reach the handler with their request untouched — including the body, which the rewritten `Request` would otherwise drop
52
52
- Bypassed responses pass through untouched: because `serialize` lives outside the resolver, a bypassed call (`cachedFunction` returns the resolver output raw — no `serialize`/`transform`) yields the handler's live `Response`, which the outer wrapper detects (`value instanceof Response`) and returns as-is. No body buffering (streaming/binary bodies survive), no synthesized cache headers, and no bogus `304` for a non-cacheable method — a **breaking behavior change** vs. the old always-serialize path (`fix(http)!`)
53
53
-`validate` rejects a **missing** body (`value.body === undefined`) but accepts `""`: a zero-byte 200 is a legal response and rejecting it would only cost hit rate. The dangerous empty body (a body-less HEAD response replayed to GET clients) is prevented by the method component in the key, not here — an empty entry is only readable by requests of the method that produced it. Documented in-place at the check so it isn't re-litigated
54
+
- Null-body statuses (`204`/`205`/`304`, `_nullBodyStatuses`) are handled on **two** sides. `validate` refuses to store them: a 204/205 has no representation to replay, and a 304 is an answer to a conditional request, not a representation — a handler doing its own conditional handling (h3 `serveStatic`, nitro public assets, an upstream-proxying route) returns one on demand, so a single crafted `If-Modified-Since: <far future>` used to store a 304 that every later **unconditional** request was served for the whole TTL. And the read path forces `body → null` for those statuses before `createResponse`, because `serialize` stores a body-less response as `""` (not nullish, so `?? null` doesn't catch it) and `new Response("", { status: 204 })` **throws** — including on the MISS, which is served through the freshly serialized entry regardless of `validate`'s verdict. Rejecting on read as well as on write means an entry written by an older ocache heals on first access. Both guards are needed: `validate` alone leaves the MISS crashing, the read-path guard alone keeps storing an unservable 304
54
55
- `.resolveKeys(event)` / `.invalidate(event)` / `.expire(event)` on the returned handler (issue #71) target the **resource, not one method variant**: they cover every cacheable method's variant of the event's resource key regardless of which method the passed event carries, so purging `/article/hello` can't leave a sibling HEAD entry advertising the dead etag/last-modified for downstream caches to revalidate against. `resolveKeys` enumerates the same set (one key per base prefix **per method variant**), the event's own variant first, so `keys[0]` is still exactly the key that event reads/writes. Implemented by feeding each variant key to the standalone `cache.ts` helpers as a fixed `getKey` — `_resolveKey` is method-free, so no event is ever cloned or mutated. `_variantOptions` calls `_resolveStorage(_opts)` first: it spreads `_opts` into one fresh options object per variant, so without pre-resolving, a purge issued before the first request would leave each copy to resolve its own storage (re-running a `storage` factory once per variant)
55
56
- Storage memo asymmetry vs `cache.ts`: `defineCachedHandler` reassigns `opts` to a merged clone on entry and clones again into `_opts`, so **the caller's own options object never receives the resolved storage** — unlike `defineCachedFunction`, which writes it back to `_optsRef`. So `invalidateCache({ options: myHandlerOpts })` will _not_ reach a handler's default storage. Deliberate: never-works is clearer than sometimes-works (the memo would otherwise land only when a purge happened to run before the first request), and reconstructing a handler key by hand is the error-prone path issue #71 exists to avoid — use the handler's own `.invalidate(event)`/`.expire(event)`/`.resolveKeys(event)`, or pass an explicit `storage` if a standalone helper must reach it
56
57
- Framework integration hooks on `CachedEventHandlerOptions`:
0 commit comments