From 72c9639dd066dfecd0d9cc464e49f7fb7c48a97f Mon Sep 17 00:00:00 2001 From: Yusuke Wada Date: Wed, 11 Sep 2024 15:04:52 +0900 Subject: [PATCH] docs(serve-static/bun,deno): add `precompressed` (#484) --- docs/getting-started/bun.md | 13 +++++++++++++ docs/getting-started/deno.md | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/docs/getting-started/bun.md b/docs/getting-started/bun.md index e4efc8d2..9779395b 100644 --- a/docs/getting-started/bun.md +++ b/docs/getting-started/bun.md @@ -150,6 +150,19 @@ app.get( ) ``` +### `precompressed` + +The `precompressed` option checks if files with extensions like `.br` or `.gz` are available and serves them based on the `Accept-Encoding` header. It prioritizes Brotli, then Zstd, and Gzip. If none are available, it serves the original file. + +```ts +app.get( + '/static/*', + serveStatic({ + precompressed: true, + }) +) +``` + ## Testing You can use `bun:test` for testing on Bun. diff --git a/docs/getting-started/deno.md b/docs/getting-started/deno.md index a5cf602a..998ece9c 100644 --- a/docs/getting-started/deno.md +++ b/docs/getting-started/deno.md @@ -137,6 +137,19 @@ app.get( ) ``` +### `precompressed` + +The `precompressed` option checks if files with extensions like `.br` or `.gz` are available and serves them based on the `Accept-Encoding` header. It prioritizes Brotli, then Zstd, and Gzip. If none are available, it serves the original file. + +```ts +app.get( + '/static/*', + serveStatic({ + precompressed: true, + }) +) +``` + ## Deno Deploy Deno Deploy is an edge runtime platform for Deno.