For AI agents: the complete documentation index is available at /next/llms.txt, the full documentation bundle is available at /next/llms-full.txt, and this page is available as Markdown at /next/api/rspeedy/rspeedy.server.compress.md.
Rspeedy logo
Rspeedy
  • English
  • Home > @lynx-js/rspeedy > Server > compress

    Server.compress property

    Configure whether to enable gzip compression for static assets served by the dev server or preview server.

    Signature:

    compress?: boolean | CompressOptions | undefined;

    Default Value

    true

    See Rsbuild - server.compress for details.

    Example 1

    To disable the gzip compression, set compress to false:

    export default {
      server: {
        compress: false,
      },
    }

    Example 2

    Compress if it starts with /foo

    export default {
      server: {
        compress: {
          filter: (req) => {
            if (req.url?.includes('/foo')) {
              return false;
            }
            return true;
          },
        },
      },
    }

    Example 3

    set level of zlib compression

    export default {
      server: {
        compress: {
          level: 6,
        },
      },
    }
    Except as otherwise noted, this work is licensed under a Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache License 2.0.