Part of the API freeze (#110). Decided: in before rc.1, designed together with compression (#112).
Static: a weak ETag from the stat the resolver already does (src/views.ts:122), W/"<size>-<mtime>", plus Last-Modified. A matching If-None-Match (or If-Modified-Since when there's no ETag) answers 304 without reading the file. Today every hit reads and sends the whole file.
Handlers:createApp({ etag: true }), off by default.
A buffered 200 to GET/HEAD gets a weak ETag from a cheap hash of the body (not a cryptographic one: weak ETags only need change detection). A matching If-None-Match becomes a 304 with no body.
An etag the handler set itself (a row version, say) is kept and only compared.
Streams are out: there's no whole body to hash.
It saves bandwidth, not work: the handler still runs. Skipping the database is already possible with @header('if-none-match') and the existing NotModified signal (src/signals.ts:60).
With compression: the hash is taken before encoding, and the ETag stays weak so it can describe every encoding of one body. The 304 carries ETag and Vary the way a 200 would.
Out:Range / 206, until someone asks. It only matters for media and resumable downloads, and it's where the edge cases pile up (multiple ranges, If-Range, 416).
Tests: static 304 without readFile (spy), handler 304, handler-set ETag respected, If-None-Match: * and lists, compression plus ETag together, and all four runtimes.
Part of the API freeze (#110). Decided: in before rc.1, designed together with compression (#112).
**Static:** a weak ETag from the `stat` the resolver already does (src/views.ts:122), `W/"<size>-<mtime>"`, plus `Last-Modified`. A matching `If-None-Match` (or `If-Modified-Since` when there's no ETag) answers 304 **without reading the file**. Today every hit reads and sends the whole file.
**Handlers:** `createApp({ etag: true })`, off by default.
- A buffered `200` to `GET`/`HEAD` gets a weak ETag from a cheap hash of the body (not a cryptographic one: weak ETags only need change detection). A matching `If-None-Match` becomes a 304 with no body.
- An `etag` the handler set itself (a row version, say) is kept and only compared.
- Streams are out: there's no whole body to hash.
- It saves bandwidth, not work: the handler still runs. Skipping the database is already possible with `@header('if-none-match')` and the existing `NotModified` signal (src/signals.ts:60).
**With compression:** the hash is taken before encoding, and the ETag stays weak so it can describe every encoding of one body. The 304 carries `ETag` and `Vary` the way a 200 would.
**Out:** `Range` / `206`, until someone asks. It only matters for media and resumable downloads, and it's where the edge cases pile up (multiple ranges, `If-Range`, 416).
**Tests:** static 304 without `readFile` (spy), handler 304, handler-set ETag respected, `If-None-Match: *` and lists, compression plus ETag together, and all four runtimes.
Fixed in 26.11.0-rc.1 (d32fc9f). From the changelog:
Static files are revalidated, not re-downloaded (#114, D12). Every static hit carries a weak ETag (W/"<size>-<mtime>"), Last-Modified and Cache-Control: no-cache. A matching If-None-Match, or If-Modified-Since when there is no If-None-Match, answers 304 from the file's stat without reading it. A HEAD no longer reads the file either. no-cache stops browsers from reusing a file for a lifetime they guessed from Last-Modified. To keep the old behaviour, set static: { cacheControl } to whatever your proxy expects.
createApp({ etag: true }) (#114, D12): weak ETags for buffered 200 responses to GET and HEAD, from a 32-bit FNV-1a hash of the body plus its length. A matching If-None-Match (weak comparison, lists, *) gets a 304 with no body. A handler that sets its own etag keeps it, and that tag drives the comparison. Streams, non-200 responses and other methods are never tagged. The handler still runs. Off by default; anything but a boolean throws at createApp.
static: { dir?, cacheControl? } (#114): the object form of static sets the Cache-Control sent with static files and their 304s (for example 'public, max-age=31536000, immutable' for hashed assets). static: true and static: '<dir>' keep working. An unknown key, or a cacheControl with CR/LF, throws at createApp.
Every 304 is bodiless (#114). A 304 has no body and no content-* headers on any adapter, including one from throw new NotModified(), which used to go out with the default JSON envelope's content-type.
Fixed in **26.11.0-rc.1** (`d32fc9f`). From the changelog:
- **Static files are revalidated, not re-downloaded** (#114, D12). Every static hit carries a weak `ETag` (`W/"<size>-<mtime>"`), `Last-Modified` and `Cache-Control: no-cache`. A matching `If-None-Match`, or `If-Modified-Since` when there is no `If-None-Match`, answers `304` from the file's `stat` without reading it. A `HEAD` no longer reads the file either. `no-cache` stops browsers from reusing a file for a lifetime they guessed from `Last-Modified`. To keep the old behaviour, set `static: { cacheControl }` to whatever your proxy expects.
- **`createApp({ etag: true })`** (#114, D12): weak ETags for buffered `200` responses to `GET` and `HEAD`, from a 32-bit FNV-1a hash of the body plus its length. A matching `If-None-Match` (weak comparison, lists, `*`) gets a `304` with no body. A handler that sets its own `etag` keeps it, and that tag drives the comparison. Streams, non-200 responses and other methods are never tagged. The handler still runs. Off by default; anything but a boolean throws at `createApp`.
- **`static: { dir?, cacheControl? }`** (#114): the object form of `static` sets the `Cache-Control` sent with static files and their `304`s (for example `'public, max-age=31536000, immutable'` for hashed assets). `static: true` and `static: '<dir>'` keep working. An unknown key, or a `cacheControl` with CR/LF, throws at `createApp`.
- **Every `304` is bodiless** (#114). A `304` has no body and no `content-*` headers on any adapter, including one from `throw new NotModified()`, which used to go out with the default JSON envelope's `content-type`.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Part of the API freeze (#110). Decided: in before rc.1, designed together with compression (#112).
Static: a weak ETag from the
statthe resolver already does (src/views.ts:122),W/"<size>-<mtime>", plusLast-Modified. A matchingIf-None-Match(orIf-Modified-Sincewhen there's no ETag) answers 304 without reading the file. Today every hit reads and sends the whole file.Handlers:
createApp({ etag: true }), off by default.200toGET/HEADgets a weak ETag from a cheap hash of the body (not a cryptographic one: weak ETags only need change detection). A matchingIf-None-Matchbecomes a 304 with no body.etagthe handler set itself (a row version, say) is kept and only compared.@header('if-none-match')and the existingNotModifiedsignal (src/signals.ts:60).With compression: the hash is taken before encoding, and the ETag stays weak so it can describe every encoding of one body. The 304 carries
ETagandVarythe way a 200 would.Out:
Range/206, until someone asks. It only matters for media and resumable downloads, and it's where the edge cases pile up (multiple ranges,If-Range, 416).Tests: static 304 without
readFile(spy), handler 304, handler-set ETag respected,If-None-Match: *and lists, compression plus ETag together, and all four runtimes.Merged into develop in #144 (CARD-15, FPRD-001c, 2026-10-23). Left open until the 1c acceptance gate (CARD-22), per the 1a/1b convention.
Fixed in 26.11.0-rc.1 (
d32fc9f). From the changelog:Static files are revalidated, not re-downloaded (#114, D12). Every static hit carries a weak
ETag(W/"<size>-<mtime>"),Last-ModifiedandCache-Control: no-cache. A matchingIf-None-Match, orIf-Modified-Sincewhen there is noIf-None-Match, answers304from the file'sstatwithout reading it. AHEADno longer reads the file either.no-cachestops browsers from reusing a file for a lifetime they guessed fromLast-Modified. To keep the old behaviour, setstatic: { cacheControl }to whatever your proxy expects.createApp({ etag: true })(#114, D12): weak ETags for buffered200responses toGETandHEAD, from a 32-bit FNV-1a hash of the body plus its length. A matchingIf-None-Match(weak comparison, lists,*) gets a304with no body. A handler that sets its ownetagkeeps it, and that tag drives the comparison. Streams, non-200 responses and other methods are never tagged. The handler still runs. Off by default; anything but a boolean throws atcreateApp.static: { dir?, cacheControl? }(#114): the object form ofstaticsets theCache-Controlsent with static files and their304s (for example'public, max-age=31536000, immutable'for hashed assets).static: trueandstatic: '<dir>'keep working. An unknown key, or acacheControlwith CR/LF, throws atcreateApp.Every
304is bodiless (#114). A304has no body and nocontent-*headers on any adapter, including one fromthrow new NotModified(), which used to go out with the default JSON envelope'scontent-type.