#compress

1 messages · Page 1 of 1 (latest)

cold valleyBOT
#

Hi @dry bay. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

By default, Next.js uses gzip to compress rendered content and static files when using next start or a custom server. This is an optimization for applications that do not have compression configured. If compression is already configured in your application via a custom server, Next.js will not add compression.

When hosting your application on Vercel, compression uses brotli first, then gzip. You can check if compression is enabled and which algorithm is used by looking at the Accept-Encoding (browser accepted options) and Content-Encoding (currently used) headers in the response.

To disable compression, set the compress config option to false in your next.config.js file:

module.exports = {
  compress: false,
}

However, it's not recommended to disable compression unless you have compression configured on your server, as compression reduces bandwidth usage and improves the performance of your application.

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, if you're using nginx and want to switch to brotli, set the compress option to false to allow nginx to handle compression.

For Next.js applications on Vercel, compression is handled by the Vercel's Edge Network and not Next.js.

Source (https://nextjs.org/docs/app/api-reference/next-config-js/compress)

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@dry bay kapa.ai is still learning and improving, please let us know how it did by reacting below

dry bay
#

I do not use Vercel. give me ways to optimize and compress code.