Skip to content

Commit 80ec26a

Browse files
Merge pull request #2270 from Scrip7/patch-1
docs(compression): fastify plugin registration should be awaited
2 parents f7e85fa + 9592381 commit 80ec26a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

content/techniques/compression.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ Once the installation is complete, apply the fastify-compress middleware as glob
3535
```typescript
3636
import compression from 'fastify-compress';
3737
// somewhere in your initialization file
38-
app.register(compression);
38+
await app.register(compression);
3939
```
4040

4141
By default, fastify-compress will use Brotli compression (on Node >= 11.7.0) when browsers indicate support for the encoding. While Brotli is quite efficient in terms of compression ratio, it's also quite slow. Due to this, you may want to tell fastify-compress to only use deflate and gzip to compress responses; you'll end up with larger responses but they'll be delivered much more quickly.
4242

4343
To specify encodings, provide a second argument to `app.register`:
4444

4545
```typescript
46-
app.register(compression, { encodings: ['gzip', 'deflate'] });
46+
await app.register(compression, { encodings: ['gzip', 'deflate'] });
4747
```
4848

4949
The above tells `fastify-compress` to only use gzip and deflate encodings, preferring gzip if the client supports both.

0 commit comments

Comments
 (0)