Skip to content

Commit a740c0e

Browse files
cursoragentlovasoa
andcommitted
Docs: Add Nginx streaming and compression configuration
Co-authored-by: contact <[email protected]>
1 parent c4ffc0d commit a740c0e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/nginx/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,24 @@ This service sets up a MySQL database with predefined credentials and a persiste
4343

4444
The `nginx.conf` file contains the NGINX configuration:
4545

46+
### Streaming and compression
47+
48+
SQLPage streams HTML as it is generated, so browsers can start rendering before the database finishes returning rows. To keep that behaviour through NGINX, prefer minimal buffering and let the proxy handle compression:
49+
50+
```
51+
proxy_buffering off;
52+
53+
gzip on;
54+
gzip_buffers 2 4k;
55+
gzip_types text/html text/plain text/css application/javascript application/json;
56+
57+
chunked_transfer_encoding on;
58+
```
59+
60+
Disabling buffering lowers latency but increases the number of active connections; tune the gzip settings to balance CPU cost versus bandwidth, and re-enable buffering only if you need request coalescing or traffic smoothing. See the [proxy buffering](https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_buffering), [gzip](https://nginx.org/en/docs/http/ngx_http_gzip_module.html), and [chunked transfer](https://nginx.org/en/docs/http/ngx_http_core_module.html#chunked_transfer_encoding) directives for more guidance.
61+
62+
When SQLPage runs behind a reverse proxy, set `compress_responses` to `false` in its configuration (documented [here](https://github.com/sqlpage/SQLPage/blob/main/configuration.md)) so that NGINX can perform compression once at the edge.
63+
4664
### Rate Limiting
4765

4866

0 commit comments

Comments
 (0)