Compression

Compression

์••์ถ•ํ•˜๋ฉด ์‘๋‹ต ๋ณธ๋ฌธ์˜ ํฌ๊ธฐ๊ฐ€ ํฌ๊ฒŒ ์ค„์–ด๋“ค์–ด ์›น ์•ฑ์˜ ์†๋„๊ฐ€ ๋นจ๋ผ์งˆ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. gzip ์••์ถ•์„ ํ™œ์„ฑํ™”ํ•˜๋ ค๋ฉด compression ๋ฏธ๋“ค์›จ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์‹ญ์‹œ์˜ค.

Installation

๋จผ์ € ํ•„์š”ํ•œ ํŒจํ‚ค์ง€๋ฅผ ์„ค์น˜ํ•˜์‹ญ์‹œ์˜ค.

$ npm i --save compression

์„ค์น˜๊ฐ€ ์™„๋ฃŒ๋˜๋ฉด ๊ธ€๋กœ๋ฒŒ ๋ฏธ๋“ค์›จ์–ด๋กœ ์ ์šฉํ•˜์‹ญ์‹œ์˜ค.

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

info ํžŒํŠธ FastifyAdapter๋กœ ์ž‘์—…ํ•˜๋Š” ๊ฒฝ์šฐ fastify-compress๋ฅผ ๋Œ€์‹  ์‚ฌ์šฉํ•ด๋ณด์‹ญ์‹œ์˜ค.

ํ”„๋กœ๋•์…˜ ํ™˜๊ฒฝ์—์„œ ํŠธ๋ž˜ํ”ฝ์ด ๋งŽ์€ ์›น ์‚ฌ์ดํŠธ์˜ ๊ฒฝ์šฐ ์••์ถ•์„ ์ ์šฉํ•˜๋Š” ๊ฐ€์žฅ ์ข‹์€ ๋ฐฉ๋ฒ•์€ ๋ฆฌ๋ฒ„์Šค ํ”„๋ก์‹œ ์ˆ˜์ค€์—์„œ ์›น ์‚ฌ์ดํŠธ๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด ๊ฒฝ์šฐ ์••์ถ• ๋ฏธ๋“ค์›จ์–ด๋ฅผ ์‚ฌ์šฉํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.

Last updated

Was this helpful?