# Compression

## Compression

압축하면 응답 본문의 크기가 크게 줄어들어 웹 앱의 속도가 빨라질 수 있습니다. gzip 압축을 활성화하려면 [compression](https://github.com/expressjs/compression) 미들웨어를 사용하십시오.

## Installation

먼저 필요한 패키지를 설치하십시오.

```bash
$ npm i --save compression
```

설치가 완료되면 글로벌 미들웨어로 적용하십시오.

```typescript
import * as compression from 'compression';
// somewhere in your initialization file
app.use(compression());
```

> info **힌트** `FastifyAdapter`로 작업하는 경우 [fastify-compress](https://github.com/fastify/fastify-compress)를 대신 사용해보십시오.

프로덕션 환경에서 **트래픽이 많은** 웹 사이트의 경우 압축을 적용하는 가장 좋은 방법은 리버스 프록시 수준에서 웹 사이트를 구현하는 것입니다. 이 경우 압축 미들웨어를 사용할 필요가 없습니다.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jakekwak.gitbook.io/nestjs/techniques/compression.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
