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
+11Lines changed: 11 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -56,6 +56,17 @@ await fastify.register(
56
56
{ global:false }
57
57
)
58
58
```
59
+
60
+
If only compression, or only decompression is desired, you can use the `globalCompression` or `globalDecompression` config flags to turn either off specifically (because the global hook is enabled by default).
61
+
62
+
```js
63
+
awaitfastify.register(
64
+
import('@fastify/compress'),
65
+
// only decompress compressed incoming requests
66
+
{ globalCompression:false }
67
+
)
68
+
```
69
+
59
70
Fastify encapsulation can be used to set global compression but run it only in a subset of routes by wrapping them inside a plugin.
60
71
61
72
> ℹ️ 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