Unverified Commit ff058d64 authored by Delba de Oliveira's avatar Delba de Oliveira Committed by GitHub

Docs: Add more clarification about `compress` (#60268)

- Add note on how to disable Next.js compression, to use a different
algorithm.

---------
Co-authored-by: 's avatarLee Robinson <me@leerob.io>
parent 052006b4
...@@ -5,11 +5,11 @@ description: Next.js provides gzip compression to compress rendered content and ...@@ -5,11 +5,11 @@ description: Next.js provides gzip compression to compress rendered content and
{/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */} {/* The content of this doc is shared between the app and pages router. You can use the `<PagesOnly>Content</PagesOnly>` component to add content that is specific to the Pages Router. Any shared content should not be wrapped in a component. */}
By default, Next.js uses `gzip` to compress rendered content and static files when using `next start` or a custom server. If compression is already configured in your application via a custom server, Next.js will not add its own compressor. By default, Next.js uses `gzip` to compress rendered content and static files when using `next start` or a custom server. This is an optmization for application's that do not have compression configured. If compression is _already_ configured in your application via a custom server, Next.js will not add compression.
> **Good to know:** > **Good to know:**
> >
> - When hosting your application on [Vercel](https://vercel.com/docs/edge-network/compression), compression uses `brotli` **and** `gzip`. > - When hosting your application on [Vercel](https://vercel.com/docs/edge-network/compression), compression uses `brotli` first, then `gzip`.
> - You can check if compression is enabled and which algorithm is used by looking at the [`Accept-Encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) (browser accepted options) and [`Content-Encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding) (currently used) headers in the response. > - You can check if compression is enabled and which algorithm is used by looking at the [`Accept-Encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding) (browser accepted options) and [`Content-Encoding`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding) (currently used) headers in the response.
## Disabling compression ## Disabling compression
...@@ -22,4 +22,14 @@ module.exports = { ...@@ -22,4 +22,14 @@ module.exports = {
} }
``` ```
We do not recommend disabling compression unless you have a specific reason to do so, as compression reduces bandwidth usage and improves the performance of your application. We do not recommend disabling compression unless you have compression configured on your server, as compression reduces bandwidth usage and improves the performance of your application.
## Changing the compression algorithm
To change your compression algorithm, you will need to configure your custom server and set the `compress` option to `false` in your `next.config.js` file.
For example, you're using [nginx](https://www.nginx.com/) and want to switch to `brotli`, set the `compress` option to `false` to allow nginx to handle compression.
> **Good to know:**
>
> - For Next.js applications on Vercel, compression is handled by the Vercel's Edge Network and not Next.js. See the [Vercel documentation](https://vercel.com/docs/edge-network/compression) for more information.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment