Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds warnings and workarounds for Brotli performance in koa-compress #8261

Merged
merged 1 commit into from
Oct 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/v3.x/concepts/middlewares.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ The session doesn't work with `mongo` as a client. The package that we should us
- `enabled` (boolean): Enable or not `X-Powered-By` header to response. Default value: `true`.
- `value` (string): The value of the header. Default value: `Strapi <strapi.io>`

::: tip
`gzip` compression via `koa-compress` uses [Brotli](https://en.wikipedia.org/wiki/Brotli) by default, but is not configured with sensible defaults for most cases. If you experience slow response times with `gzip` enabled, consider disabling Brotli by passing `{br: false}` as an option. You may also pass more sensible params with `{br: { params: { // YOUR PARAMS HERE } }}`
derrickmehaffy marked this conversation as resolved.
Show resolved Hide resolved
:::

### Security middlewares

- [`csp`](https://en.wikipedia.org/wiki/Content_Security_Policy)
Expand Down
17 changes: 17 additions & 0 deletions docs/v3.x/deployment/heroku.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,20 @@ heroku open
Like with project updates on Heroku, the file system doesn't support local uploading of files as they will be wiped when Heroku "Cycles" the dyno. This type of file system is called [ephemeral](https://devcenter.heroku.com/articles/dynos#ephemeral-filesystem), which means the file system only lasts until the dyno is restarted (with Heroku this happens any time you redeploy or during their regular restart which can happen every few hours or every day).

Due to Heroku's filesystem you will need to use an upload provider such as AWS S3, Cloudinary, or Rackspace. You can view the documentation for installing providers [here](../plugins/upload.md#install-providers) and you can see a list of providers from both Strapi and the community on [npmjs.com](https://www.npmjs.com/search?q=strapi-provider-upload-&page=0&perPage=20).

### Gzip

As of version `3.2.1`, Strapi uses [`koa-compress`](https://github.com/koajs/compress) v5, which enables [Brotli](https://en.wikipedia.org/wiki/Brotli) compression by default. At the time of writing, the default configuration for Brotli results in poor performance, causing very slow response times and potentially response timeouts. If you plan on enabling the [gzip middleware](../concepts/middlewares.html#core-middleware-configurations), it is recommended that you disable Brotli or define better configuration params.

To disable Brotli, provide the following configuration in `config/middleware.js`.

```jsonify
gzip: {
enabled: true,
options: {
br: false
}
},
```

For more on Brotli configuration for `koa-compress`, reference [this issue](https://github.com/koajs/compress/issues/121).