From 89fae174a1ea10f59ae248fe030d9b7e83d0b8a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jun-Ah=20=EC=A4=80=EC=95=84?= Date: Tue, 26 Mar 2024 02:57:47 +0900 Subject: [PATCH] Add missing `compresslevel` parameter on docs (#2553) * Add missing compresslevel parameter on docs The compresslevel parameter was added in #1128. But, it was not added to the document, so an explanation was added. * Update docs/middleware.md --------- Co-authored-by: Marcelo Trylesinski --- docs/middleware.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/middleware.md b/docs/middleware.md index 759c86d70..dfe0a70d7 100644 --- a/docs/middleware.md +++ b/docs/middleware.md @@ -185,7 +185,7 @@ from starlette.middleware.gzip import GZipMiddleware routes = ... middleware = [ - Middleware(GZipMiddleware, minimum_size=1000) + Middleware(GZipMiddleware, minimum_size=1000, compresslevel=9) ] app = Starlette(routes=routes, middleware=middleware) @@ -194,6 +194,7 @@ app = Starlette(routes=routes, middleware=middleware) The following arguments are supported: * `minimum_size` - Do not GZip responses that are smaller than this minimum size in bytes. Defaults to `500`. +* `compresslevel` - Used during GZip compression. It is an integer ranging from 1 to 9. Defaults to `9`. Lower value results in faster compression but larger file sizes, while higher value results in slower compression but smaller file sizes. The middleware won't GZip responses that already have a `Content-Encoding` set, to prevent them from being encoded twice.