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: README.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,6 +57,23 @@ await fastify.register(
57
57
{ global:false }
58
58
)
59
59
```
60
+
61
+
If only compression or decompression is required, set the `globalCompression` or `globalDecompression` config flags to `false` respectively (both are `true` by default).
62
+
63
+
```js
64
+
awaitfastify.register(
65
+
import('@fastify/compress'),
66
+
// Disable compression but keep decompression enabled (default behavior for globalDecompression is true)
67
+
{ globalCompression:false }
68
+
)
69
+
70
+
// Disable decompression but keep compression enabled
71
+
awaitfastify.register(
72
+
import('@fastify/compress'),
73
+
{ globalDecompression:false }
74
+
)
75
+
```
76
+
60
77
Fastify encapsulation can be used to set global compression but run it only in a subset of routes by wrapping them inside a plugin.
61
78
62
79
> ℹ️ Note: If using `@fastify/compress` plugin together with `@fastify/static` plugin, `@fastify/compress` must be registered (with *global hook*) **before** registering `@fastify/static`.
0 commit comments