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
Copy file name to clipboardExpand all lines: docs/content/configuration/environment-variables.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -78,10 +78,13 @@ Specify an optional CORS list of allowed HTTP headers separated by commas. It re
78
78
Specify an optional CORS list of exposed HTTP headers separated by commas. It requires `SERVER_CORS_ALLOW_ORIGINS` to be used along with. Default `origin, content-type`.
79
79
80
80
### SERVER_COMPRESSION
81
-
`Gzip`, `Deflate` or `Brotli` compression on demand determined by the `Accept-Encoding` header and applied to text-based web file types only. See [ad-hoc mime-type list](https://github.com/static-web-server/static-web-server/blob/master/src/compression.rs#L20). Default `true` (enabled).
81
+
`Gzip`, `Deflate`, `Brotli` or `zlib` compression on demand determined by the `Accept-Encoding` header and applied to text-based web file types only. See [ad-hoc mime-type list](https://github.com/static-web-server/static-web-server/blob/master/src/compression.rs#L20). Default `true` (enabled).
82
+
83
+
### SERVER_COMPRESSION_LEVEL
84
+
Supported values are `fastest` (fast compression but larger resulting files), `best` (smallest file size but potentially slow) and `default` (algorithm-specific balanced compression level). Default is `default`.
82
85
83
86
### SERVER_COMPRESSION_STATIC
84
-
Look up the pre-compressed file variant (`.gz`or `.br`) on disk of a requested file and serves it directly if available. Default `false` (disabled). The compression type is determined by the `Accept-Encoding` header.
87
+
Look up the pre-compressed file variant (`.gz`, `.br`or `.zst`) on disk of a requested file and serves it directly if available. Default `false` (disabled). The compression type is determined by the `Accept-Encoding` header.
85
88
86
89
### SERVER_DIRECTORY_LISTING
87
90
Enable directory listing for all requests ending with the slash character (‘/’). Default `false` (disabled).
Copy file name to clipboardExpand all lines: docs/content/features/compression.md
+20-27Lines changed: 20 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,44 +2,37 @@
2
2
3
3
**`SWS`** provides [`Gzip`](https://datatracker.ietf.org/doc/html/rfc1952), [`Deflate`](https://datatracker.ietf.org/doc/html/rfc1951#section-Abstract), [`Brotli`](https://www.ietf.org/rfc/rfc7932.txt) and [`Zstandard` (zstd)](https://datatracker.ietf.org/doc/html/rfc8878) compression of HTTP responses.
4
4
5
-
The compression functionality is determined by the [`Accept-Encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) header and is only applied to text-based web file types.
5
+
This feature is enabled by default and can be controlled by the boolean `-x, --compression` option or the equivalent [SERVER_COMPRESSION](../configuration/environment-variables.md#server_compression) env.
6
+
7
+
```sh
8
+
static-web-server \
9
+
--port 8787 \
10
+
--root ./my-public-dir \
11
+
--compression true
12
+
```
13
+
14
+
## Choice of compression algorithm
15
+
16
+
The compression algorithm is determined by the [`Accept-Encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) header and the compression support built into SWS. By default SWS builds with support for `Gzip`, `Deflate`, `Brotli` and `Zstandard` algorithms.
6
17
7
18
## MIME types compressed
8
19
9
-
Only this list of common text-based MIME-type files will be compressed either with `Gzip`, `Deflate` or `Brotli` via the `Accept-Encoding` header value.
20
+
Compression is only applied to files with the MIME types listed below, indicating text and similarly well compressing formats. The asterisk `*` is a placeholder indicating an arbitrary MIME type part.
10
21
11
22
```txt
12
-
text/html
13
-
text/css
14
-
text/javascript
15
-
text/xml
16
-
text/plain
17
-
text/csv
18
-
text/calendar
19
-
text/markdown
20
-
text/x-yaml
21
-
text/x-toml
22
-
text/x-component
23
+
text/*
24
+
*+xml
25
+
*+json
23
26
application/rtf
24
-
application/xhtml+xml
25
27
application/javascript
26
-
application/x-javascript
27
28
application/json
28
29
application/xml
29
-
application/rss+xml
30
-
application/atom+xml
30
+
font/ttf
31
+
application/font-sfnt
31
32
application/vnd.ms-fontobject
32
-
font/truetype
33
-
font/opentype
34
-
image/svg+xml
35
33
application/wasm
36
34
```
37
35
38
-
This feature is enabled by default and can be controlled by the boolean `-x, --compression` option or the equivalent [SERVER_COMPRESSION](./../configuration/environment-variables.md#server_compression) env.
36
+
## Compression level
39
37
40
-
```sh
41
-
static-web-server \
42
-
--port 8787 \
43
-
--root ./my-public-dir \
44
-
--compression true
45
-
```
38
+
SWS allows selecting the compression level via `--compression-level` command line option or the equivalent [SERVER_COMPRESSION_LEVEL](../configuration/environment-variables.md#server_compression_level) env. The available values are `fastest`, `best` and `default`. `fastest` will result in the lowest CPU load but also the worst compression factor. `best` will attempt to compress the data as much as possible (not recommended with `Brotli` or `Zstandard` compression, will be very slow). `default` tries to strike a balance, choosing a compression level where compression factor is already fairly good but the CPU load is still low.
0 commit comments