forked from ehmicky/Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompression.express.txt
More file actions
36 lines (28 loc) · 1.82 KB
/
compression.express.txt
File metadata and controls
36 lines (28 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
┏━━━━━━━━━━━━━━━━━┓
┃ COMPRESSION ┃
┗━━━━━━━━━━━━━━━━━┛
ALTERNATIVES ==> # - Express compression (preferred with Express)
# - gzip|deflate|br
# - better logic
# - @middy/http-content-encoding (preferred with Middy)
# - gzip|deflate|br
VERSION ==> #1.8.0
COMPRESSION([OPTS])->EXPRESS_MDWR #Compresses RES
#Do so by monkey-patching underlying RES.write|end|flush(), using ZLIB.createGzip|Deflate|BrotliCompress()
Accept-Encoding:
identity|gzip|deflate|br [C] #Used to determinate compression and which algo (using NEGOTIATOR, see its doc)
Cache-Control: no-transform [C] #Do not compress if set
Vary: Accept-Encoding [S] #Set
Content-Encoding:
gzip|deflate|br [S] #Set
Transfer-Encoding: chunked [S] #Set
Content-Length [S] #Unset
OPTS.filter #FUNC(REQ, RES)->BOOL. Only compress if returns true.
#Def: uses compressible (see its doc)
OPTS.threshold #NUM (def: 1KB). Only compress if larger than that
#Can be STR (uses bytes, see its doc)
OPTS.enforceEncoding #STR|'*' (def: 'identity')
#Default Accept-Encoding [C] if not specified
OPTS.* #Passed to ZLIB.createGzip|Deflate(OPTS)
OPTS.brotli #Passed to ZLIB.createBrotliCompress(OPTS.brotli)
#Def quality: 4