mod_deflate ³»¿ëÀ» Ŭ¶óÀ̾ðÆ®·Î º¸³»±â Àü¿¡ ¾ÐÃàÇÑ´Ù Extension mod_deflate.c deflate_module

mod_deflate ¸ðµâÀº ¼­¹öÀÇ Ãâ·ÂÀ» ³×Æ®¿÷À¸·Î Ŭ¶óÀ̾ðÆ®¿¡ º¸³»±â Àü¿¡ ¾ÐÃàÇÏ´Â DEFLATE Ãâ·ÂÇÊÅ͸¦ Á¦°øÇÑ´Ù.

ÇÊÅÍ
¾ÐÃàÇϱâ
Ãâ·Â ¾ÐÃà

DEFLATE ÇÊÅÍ°¡ ¾ÐÃàÀ» ÇÑ´Ù. ´ÙÀ½ Áö½Ã¾î´Â Áö½Ã¾î°¡ ÀÖ´Â À§Ä¡ÀÇ ¹®¼­¸¦ ¾ÐÃàÇÑ´Ù:

SetOutputFilter DEFLATE

¸ðµç ³»¿ëÀ» ¾ÐÃàÇϸé ó¸®ÇÏÁö ¸øÇÏ´Â ºê¶ó¿ìÀú°¡ Àֱ⶧¹®¿¡ html ÆÄÀϸ¸À» ¾ÐÃàÇϱâÀ§ÇØ (¾Æ·¡ Âü°í) gzip-only-text/htmlÀ» 1·Î ¼³Á¤ÇÒÁöµµ ¸ð¸¥´Ù. À̸¦ 1ÀÌ ¾Æ´Ñ °ªÀ¸·Î ¼³Á¤ÇÏ¸é ¹«½ÃÇÑ´Ù.

º¸Åë Ưº°ÇÑ MIME type¸¸ ¾ÐÃàÇÏ·Á¸é AddOutputFilterByType Áö½Ã¾î¸¦ »ç¿ëÇÑ´Ù. ´ÙÀ½ ¼³Á¤Àº html ÆÄÀϸ¸À» ¾ÐÃàÇÑ´Ù:

<Directory "/your-server-root/manual">
AddOutputFilterByType DEFLATE text/html
</Directory>

¾ÐÃàÇÑ ÆÄÀÏÀ» ó¸®ÇÏÁö ¸øÇÏ´Â ºê¶ó¿ìÀú¿¡°Ô´Â ¾ÐÃàÇÏÁö¾Ê°í º¸³»±æÀ§ÇØ BrowserMatch Áö½Ã¾î¿¡ no-gzipÀ» ¼³Á¤ÇÑ´Ù. ÃÖÀûÀÇ °á°ú¸¦ ¾ò±âÀ§ÇØ no-gzip°ú gzip-only-text/htmlÀ» °°ÀÌ »ç¿ëÇÒ ¼ö ÀÖ´Ù. ÀÌ °æ¿ì ÀüÀÚ°¡ ÈÄÀÚ¸¦ ¹«½ÃÇÑ´Ù. À§ ÀýÀÇ ¼³Á¤ ¿¹Á¦ ÀϺθ¦ »ìÆ캸ÀÚ:

BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

¸ÕÀú User-Agent ¹®ÀÚ¿­À» º¸°í Netscape Navigator ¹öÀü 4.xÀÎÁö °Ë»çÇÑ´Ù. ÀÌ ¹öÀüÀº text/htmlÀÌ ¾Æ´Ñ typeÀÇ ¾ÐÃàÀ» ó¸®ÇÏÁö ¸øÇÑ´Ù. ¹öÀü 4.06, 4.07, 4.08Àº html ÆÄÀÏ ¾ÐÃàÀ» ó¸®Çϴ´뵵 ¹®Á¦°¡ ÀÖ´Ù. ±×·¡¼­ ¿ì¸®´Â ÀÌ °æ¿ì deflate ÇÊÅ͸¦ ¿ÏÀüÈ÷ »ç¿ëÇÏÁö¾Ê´Â´Ù.

¼¼¹ø° BrowserMatch Áö½Ã¾î´Â Microsoft Internet Explorer°¡ ÀÚ½ÅÀ» "Mozilla/4"·Î ¾Ë¸®Áö¸¸ ¾ÐÃàµÈ ¿äûÀ» ó¸®ÇÒ ¼ö Àֱ⶧¹®¿¡ user agent ÃßÃøÀ» ¼öÁ¤ÇÑ´Ù. User-Agent Çì´õ¿¡¼­ "MSIE" (\b´Â "´Ü¾î °æ°è"¸¦ ¶æÇÑ´Ù) ¹®ÀÚ¿­À» ¹ß°ßÇÏ¸é ¾Õ¿¡¼­ ¼³Á¤ÇÑ Á¦¾àÀ» Ǭ´Ù.

ÁÖÀÇ DEFLATE ÇÊÅÍ´Â Ç×»ó PHP³ª SSI¿Í °°Àº RESOURCE ÇÊÅÍ µÚ¿¡ µé¾î°£´Ù. ¶Ç, ³»ºÎ ÇÏÀ§¿äû(subrequest)¿¡ ¿µÇâÀ» ÁÖÁö ¾Ê´Â´Ù. ÁÖÀÇ SetEnv·Î force-gzip ȯ°æº¯¼ö¸¦ ¼³Á¤ÇÏ¸é ºê¶ó¿ìÀúÀÇ accept-encoding ¼³Á¤À» ¹«½ÃÇÏ°í ¾ÐÃàµÈ °á°ú¸¦ º¸³½´Ù.
Ãâ·Â ¾ÐÃàÇ®±â

mod_deflate ¸ðµâÀº gzipÀ¸·Î ¾ÐÃàµÈ ÀÀ´ä ³»¿ëÀ» Ǫ´Â ÇÊÅ͵µ Á¦°øÇÑ´Ù. ÀÌ ±â´ÉÀ» »ç¿ëÇÏ·Á¸é ´ÙÀ½°ú °°ÀÌ SetOutputFilter³ª AddOutputFilter¸¦ »ç¿ëÇÏ¿© Ãâ·ÂÇÊÅͼø¼­¿¡ INFLATE ÇÊÅ͸¦ Ãß°¡ÇÑ´Ù.

<Location /dav-area>
ProxyPass http://example.com/
SetOutputFilter INFLATE
</Location>

ÀÌ ¿¹Á¦´Â example.comÀÌ º¸³½ gzipÀ¸·Î ¾ÐÃàµÈ °á°úÀÇ ¾ÐÃàÀ» Ç®¾î¼­, ´Ù¸¥ ÇÊÅÍ°¡ ´õ ó¸®ÇÒ ¼ö ÀÖµµ·Ï ÇÑ´Ù.

ÀÔ·Â ¾ÐÃàÇ®±â

mod_deflate ¸ðµâÀº gzipÀ¸·Î ¾ÐÃàµÈ ¿äû ³»¿ëÀ» Ǫ´Â ÇÊÅ͵µ Á¦°øÇÑ´Ù. ÀÌ ±â´ÉÀ» »ç¿ëÇÏ·Á¸é ´ÙÀ½°ú °°ÀÌ SetInputFilter³ª AddInputFilter¸¦ »ç¿ëÇÏ¿© ÀÔ·ÂÇÊÅͼø¼­¿¡ DEFLATE ÇÊÅ͸¦ Ãß°¡ÇÑ´Ù.

<Location /dav-area>
SetInputFilter DEFLATE
</Location>

¿äû¿¡ Content-Encoding: gzip Çì´õ°¡ ÀÖ´Ù¸é ÀÚµ¿À¸·Î ¾ÐÃàµÈ ³»¿ëÀ» Ǭ´Ù. gzip ¿äûÀ» ÇÒ ¼ö ÀÖ´Â ºê¶ó¿ìÀú´Â µå¹°´Ù. ±×·¯³ª ¾î¶² WebDAV Ŭ¶óÀ̾ðÆ®¿Í °°Àº Ưº°ÇÑ ÇÁ·Î±×·¥Àº ¿äû ¾ÐÃàÀ» Áö¿øÇÑ´Ù.

Content-Length¿¡ ´ëÇÑ ÁÖÀÇ

¿äû ³»¿ëÀ» Á÷Á¢ »ìÆ캻´Ù¸é, Content-Length Çì´õ¸¦ ¹ÏÁö¸¶¶ó! Content-Length Çì´õ´Â Ŭ¶óÀ̾ðÆ®°¡ º¸³½ ³»¿ëÀÇ ±æÀÌÀÌÁö, ¾ÐÃàÀ» Ǭ °á°úÀÇ ¹ÙÀÌÆ®¼ö°¡ ¾Æ´Ï´Ù.

ÇÁ·Ï½Ã ¼­¹ö ´Ù·ç±â

mod_deflate ¸ðµâÀº ÇÁ·Ï½Ã°¡ ÀÚ½ÅÀÌ Ä³½¬ÇÑ ÀÀ´äÀ» ÀûÀýÇÑ Accept-Encoding ¿äû Çì´õ¸¦ º¸³½ Ŭ¶óÀ̾ðÆ®¿¡°Ô¸¸ º¸³»µµ·Ï Vary: Accept-Encoding HTTP ÀÀ´ä Çì´õ¸¦ Ãß°¡ÇÑ´Ù. ±×·¡¼­ ¾ÐÃàµÈ ³»¿ëÀ» ÀÌÇØÇÒ ¼ö ¾ø´Â Ŭ¶óÀ̾ðÆ®¿¡ ¾ÐÃàµÈ ³»¿ëÀ» º¸³»Áö¾Êµµ·Ï ÇÑ´Ù.

¿¹¸¦ µé¾î, User-Agent Çì´õ µî¿¡ µû¶ó Ưº°È÷ ÇÊÅÍ Àû¿ëÀ» Ãë¼ÒÇÑ´Ù¸é, ÇÁ·Ï½Ã¿¡°Ô ÀÌ·¯ÇÑ Á¦ÇÑÀ» ¾Ë·ÁÁÖ±âÀ§ÇØ Á÷Á¢ Vary Çì´õ¿¡ Ãß°¡ÇØ¾ß ÇÑ´Ù. ¿¹¸¦ µé¾î, ¼³Á¤ÀÌ User-Agent¿¡ µû¶ó DEFLATE ÇÊÅ͸¦ Ãß°¡ÇÑ´Ù¸é ´ÙÀ½À» »ç¿ëÇÑ´Ù:

Header append Vary User-Agent

¿äû Çì´õ¿ÜÀÇ ´Ù¸¥ Á¤º¸¿¡ (¿¹¸¦ µé¾î, HTTP ¹öÀü) µû¶ó ¾ÐÃà ¿©ºÎ°¡ °áÁ¤µÈ´Ù¸é, Vary Çì´õ°ªÀ» *·Î ¼³Á¤ÇØ¾ß ÇÑ´Ù. ±×·¯¸é Ç¥ÁØÀ» µû¸£´Â ÇÁ·Ï½Ã´Â ij½¬¸¦ ÇÏÁö ¾Ê°Ô µÈ´Ù.

¿¹Á¦ Header set Vary *
DeflateFilterNote ¾ÐÃà·üÀ» ·Î±×¿¡ ±â·ÏÇÑ´Ù DeflateFilterNote [type] notename server configvirtual host typeÀº ¾ÆÆÄÄ¡ 2.0.4 ºÎÅÍ

DeflateFilterNote Áö½Ã¾î´Â ¿äûÀÇ ¾ÐÃà·üÀ» ·Î±×¿¡ ±â·ÏÇÏ´Â ±âÈ£¸¦ ÁöÁ¤ÇÑ´Ù. ±âÈ£ À̸§Àº Áö½Ã¾î·Î ÁöÁ¤ÇÑ °ªÀÌ´Ù. Åë°è¸¦ À§ÇØ Á¢±Ù ·Î±×¿¡¼­ ±âÈ£¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù.

¿¹Á¦ DeflateFilterNote ratio

LogFormat '"%r" %b (%{ratio}n) "%{User-agent}i"' deflate
CustomLog logs/deflate_log deflate

·Î±×¿¡¼­ ´õ Á¤È®ÇÑ °ªÀ» ÃßÃâÇÏ·Á¸é type ¾Æ±Ô¸ÕÆ®·Î ±â·ÏÇÒ ÀڷḦ ¼±ÅÃÇÑ´Ù. type´Â ´ÙÀ½Áß ÇϳªÀÌ´Ù:

Input
ÇÊÅÍ ÀԷ½ºÆ®¸²ÀÇ ¹ÙÀÌÆ®¼ö¸¦ ÀúÀåÇÑ´Ù.
Output
ÇÊÅÍ Ãâ·Â½ºÆ®¸²ÀÇ ¹ÙÀÌÆ®¼ö¸¦ ÀúÀåÇÑ´Ù..
Ratio
¾ÐÃà·üÀ» (output/input * 100) ÀúÀåÇÑ´Ù. type ¾Æ±Ô¸ÕÆ®¸¦ »ý·«ÇÏ¸é »ç¿ëÇÏ´Â ±âº»°ªÀÌ´Ù.

±×·¡¼­ ÀÌ·¸°Ô ·Î±×¿¡ ±â·ÏÇÒ ¼ö ÀÖ´Ù:

Á¤¹ÐÇÑ ·Î±× DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio

LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate_log deflate
mod_log_config
DeflateBufferSize zlibÀÌ Çѹø¿¡ ¾ÐÃàÇÒ Å©±â DeflateBufferSize value DeflateBufferSize 8096 server configvirtual host

DeflateBufferSize Áö½Ã¾î´Â zlibÀÌ Çѹø¿¡ ¾ÐÃàÇÒ ¹ÙÀÌÆ®¼ö¸¦ ÁöÁ¤ÇÑ´Ù.

DeflateWindowSize Zlib ¾ÐÃà window size DeflateWindowSize value DeflateWindowSize 15 server configvirtual host

DeflateWindowSize Áö½Ã¾î´Â zlib ¾ÐÃà window size¸¦ (1°ú 15 »çÀÌÀÇ °ª) ÁöÁ¤ÇÑ´Ù. ÀϹÝÀûÀ¸·Î window size°¡ Ŭ¼ö·Ï ¾ÐÃà·üÀÌ Áõ°¡ÇÑ´Ù.

DeflateMemLevel zlibÀÌ ¾ÐÃàÇÒ¶§ »ç¿ëÇÏ´Â ¸Þ¸ð¸®·® DeflateMemLevel value DeflateMemLevel 9 server configvirtual host

DeflateMemLevel Áö½Ã¾î´Â zlibÀÌ ¾ÐÃàÇÒ¶§ ¾ó¸¶¸¸Å­ ¸Þ¸ð¸®¸¦ »ç¿ëÇÒÁö °áÁ¤ÇÑ´Ù. (1°ú 9 »çÀÌÀÇ °ª)

DeflateCompressionLevel Ãâ·ÂÀ» ¾î´ÀÁ¤µµ ¾ÐÃàÇϴ°¡ DeflateCompressionLevel value Zlib's default server configvirtual host ¾ÆÆÄÄ¡ 2.0.45 ºÎÅÍ

DeflateCompressionLevel Áö½Ã¾î´Â »ç¿ëÇÒ ¾ÐÃà¼öÁØÀ» ¼±ÅÃÇÑ´Ù. °ªÀÌ Å¬¼ö·Ï ¾ÐÃà·üÀÌ Áõ°¡ÇÏÁö¸¸, CPU¸¦ ´õ ¸¹ÀÌ »ç¿ëÇÑ´Ù.

(°¡Àå ´ú ¾ÐÃà) 1°ú (°¡Àå ¸¹ÀÌ ¾ÐÃà) 9 »çÀÌÀÇ °ªÀ» ÁöÁ¤ÇÑ´Ù.