Skip to content

Commit 928a160

Browse files
committed
docs: Clarify which payloads skip request-body compression
1 parent 286f68b commit 928a160

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

docs/02_concepts/13_http_compression.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ The client compresses request bodies using the compressor configured via the `co
1919

2020
## Already-compressed payloads
2121

22-
Some payloads carry their own compression, so compressing them again costs CPU and memory while typically making the request slightly larger. The client skips compression when the request's `Content-Type` is one of these:
22+
Some payloads carry their own compression, so compressing them again costs CPU and memory while making the request slightly larger. The client skips compression when the request's `Content-Type` is one of these:
2323

24-
- any `image/*`, `audio/*`, or `video/*` type,
25-
- archives such as `application/zip`, `application/gzip`, or `application/x-7z-compressed`,
26-
- web fonts (`font/woff`, `font/woff2`).
24+
- any `image/*`, `audio/*`, or `video/*` type
25+
- archives such as `application/zip`, `application/gzip`, or `application/x-7z-compressed`
26+
- office documents and packages built on ZIP, such as `.docx`, `.xlsx`, `.epub`, or `.apk`
27+
- web fonts (`font/woff`, `font/woff2`)
2728

28-
Text-based types are still compressed even under those prefixes, so `image/svg+xml` is compressed as usual. Set an accurate `content_type` when uploading media to a key-value store to benefit from this:
29+
Two kinds of media type are compressed anyway: raw formats such as `image/bmp`, `image/tiff`, and `audio/wav`, and subtypes with a structured syntax suffix such as `image/svg+xml`. Set an accurate `content_type` when uploading media to a key-value store:
2930

3031
<Tabs>
3132
<TabItem value="AsyncExample" label="Async client" default>
@@ -40,7 +41,7 @@ Text-based types are still compressed even under those prefixes, so `image/svg+x
4041
</TabItem>
4142
</Tabs>
4243

43-
Without an explicit content type the record is sent as `application/octet-stream`, which the client cannot tell apart from uncompressed binary data and therefore still compresses.
44+
Without an explicit content type, a `bytes` value is sent as `application/octet-stream`, which the client can't tell apart from uncompressed binary data and therefore still compresses. File-like values are streamed rather than buffered, so they're never compressed regardless of their content type.
4445

4546
## Configuration
4647

docs/02_concepts/code/13_skip_compression_async.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,7 @@ async def main() -> None:
1414

1515
# The explicit content type lets the client skip compressing the PNG.
1616
await kvs_client.set_record('screenshot', screenshot, content_type='image/png')
17+
18+
19+
if __name__ == '__main__':
20+
asyncio.run(main())

0 commit comments

Comments
 (0)